public static void SetShaderForData(Player player, int cHead, ref DrawData cdd) { int localShaderIndex; PlayerDrawHelper.ShaderConfiguration shaderType; PlayerDrawHelper.UnpackShader(cdd.shader, out localShaderIndex, out shaderType); switch (shaderType) { case PlayerDrawHelper.ShaderConfiguration.ArmorShader: GameShaders.Hair.Apply((short)0, player, new DrawData?(cdd)); GameShaders.Armor.Apply(localShaderIndex, (Entity)player, new DrawData?(cdd)); break; case PlayerDrawHelper.ShaderConfiguration.HairShader: if (player.head == 0) { GameShaders.Hair.Apply((short)0, player, new DrawData?(cdd)); GameShaders.Armor.Apply(cHead, (Entity)player, new DrawData?(cdd)); break; } GameShaders.Armor.Apply(0, (Entity)player, new DrawData?(cdd)); GameShaders.Hair.Apply((short)localShaderIndex, player, new DrawData?(cdd)); break; case PlayerDrawHelper.ShaderConfiguration.TileShader: Main.tileShader.CurrentTechnique.Passes[localShaderIndex].Apply(); break; case PlayerDrawHelper.ShaderConfiguration.TilePaintID: if (localShaderIndex == 31) { GameShaders.Armor.Apply(0, (Entity)player, new DrawData?(cdd)); break; } Main.tileShader.CurrentTechnique.Passes[Main.ConvertPaintIdToTileShaderIndex(localShaderIndex, false, false)].Apply(); break; } }
public static void DrawPlayer_RenderAllLayers(PlayerDrawHeadSet drawinfo) { List <DrawData> drawData = drawinfo.DrawData; Effect pixelShader = Main.pixelShader; _ = Main.projectile; SpriteBatch spriteBatch = Main.spriteBatch; for (int i = 0; i < drawData.Count; i++) { DrawData cdd = drawData[i]; if (!cdd.sourceRect.HasValue) { cdd.sourceRect = cdd.texture.Frame(); } PlayerDrawHelper.SetShaderForData(drawinfo.drawPlayer, drawinfo.cHead, cdd); if (cdd.texture != null) { cdd.Draw(spriteBatch); } } pixelShader.CurrentTechnique.Passes[0].Apply(); }
public static void DrawPlayer_RenderAllLayers(ref PlayerDrawHeadSet drawinfo) { List <DrawData> drawData = drawinfo.DrawData; Effect pixelShader = Main.pixelShader; Projectile[] projectile = Main.projectile; SpriteBatch spriteBatch = Main.spriteBatch; for (int index = 0; index < drawData.Count; ++index) { DrawData cdd = drawData[index]; if (!cdd.sourceRect.HasValue) { cdd.sourceRect = new Rectangle?(cdd.texture.Frame(1, 1, 0, 0, 0, 0)); } PlayerDrawHelper.SetShaderForData(drawinfo.drawPlayer, drawinfo.cHead, ref cdd); if (cdd.texture != null) { cdd.Draw(spriteBatch); } } pixelShader.CurrentTechnique.Passes[0].Apply(); }
public void BoringSetup(Player drawPlayer2, List <DrawData> drawData, List <int> dust, List <int> gore, float X, float Y, float Alpha, float Scale) { DrawData = drawData; Dust = dust; Gore = gore; drawPlayer = drawPlayer2; Position = drawPlayer.position; cHead = 0; cFace = 0; cUnicornHorn = 0; drawUnicornHorn = false; skinVar = drawPlayer.skinVariant; hairShaderPacked = PlayerDrawHelper.PackShader(drawPlayer.hairDye, PlayerDrawHelper.ShaderConfiguration.HairShader); if (drawPlayer.head == 0 && drawPlayer.hairDye == 0) { hairShaderPacked = PlayerDrawHelper.PackShader(1, PlayerDrawHelper.ShaderConfiguration.HairShader); } skinDyePacked = drawPlayer.skinDyePacked; if (drawPlayer.face > 0 && drawPlayer.face < 16) { Main.instance.LoadAccFace(drawPlayer.face); } cHead = drawPlayer.cHead; cFace = drawPlayer.cFace; cUnicornHorn = drawPlayer.cUnicornHorn; drawUnicornHorn = drawPlayer.hasUnicornHorn; Main.instance.LoadHair(drawPlayer.hair); scale = Scale; colorEyeWhites = Main.quickAlpha(Color.White, Alpha); colorEyes = Main.quickAlpha(drawPlayer.eyeColor, Alpha); colorHair = Main.quickAlpha(drawPlayer.GetHairColor(useLighting: false), Alpha); colorHead = Main.quickAlpha(drawPlayer.skinColor, Alpha); colorArmorHead = Main.quickAlpha(Color.White, Alpha); playerEffect = SpriteEffects.None; if (drawPlayer.direction < 0) { playerEffect = SpriteEffects.FlipHorizontally; } headVect = new Vector2((float)drawPlayer.legFrame.Width * 0.5f, (float)drawPlayer.legFrame.Height * 0.4f); bodyFrameMemory = drawPlayer.bodyFrame; bodyFrameMemory.Y = 0; Position = Main.screenPosition; Position.X += X; Position.Y += Y; Position.X -= 6f; Position.Y -= 4f; Position.Y -= drawPlayer.HeightMapOffset; if (drawPlayer.head > 0 && drawPlayer.head < 266) { Main.instance.LoadArmorHead(drawPlayer.head); int num = ArmorIDs.Head.Sets.FrontToBackID[drawPlayer.head]; if (num >= 0) { Main.instance.LoadArmorHead(num); } } if (drawPlayer.face > 0 && drawPlayer.face < 16) { Main.instance.LoadAccFace(drawPlayer.face); } helmetOffset = drawPlayer.GetHelmetDrawOffset(); drawPlayer.GetHairSettings(out fullHair, out hatHair, out hideHair, out var _, out helmetIsOverFullHair); helmetIsTall = drawPlayer.head == 14 || drawPlayer.head == 56 || drawPlayer.head == 158; helmetIsNormal = !helmetIsTall && !helmetIsOverFullHair && drawPlayer.head > 0 && drawPlayer.head < 266 && drawPlayer.head != 28; }
public void BoringSetup( Player drawPlayer2, List <Terraria.DataStructures.DrawData> drawData, List <int> dust, List <int> gore, float X, float Y, float Alpha, float Scale) { this.DrawData = drawData; this.Dust = dust; this.Gore = gore; this.drawPlayer = drawPlayer2; this.Position = this.drawPlayer.position; this.cHead = 0; this.cFace = 0; this.cUnicornHorn = 0; this.drawUnicornHorn = false; this.skinVar = this.drawPlayer.skinVariant; this.hairShaderPacked = PlayerDrawHelper.PackShader((int)this.drawPlayer.hairDye, PlayerDrawHelper.ShaderConfiguration.HairShader); if (this.drawPlayer.head == 0 && this.drawPlayer.hairDye == (byte)0) { this.hairShaderPacked = PlayerDrawHelper.PackShader(1, PlayerDrawHelper.ShaderConfiguration.HairShader); } this.skinDyePacked = this.drawPlayer.skinDyePacked; if (this.drawPlayer.face > (sbyte)0 && this.drawPlayer.face < (sbyte)16) { Main.instance.LoadAccFace((int)this.drawPlayer.face); } this.cHead = this.drawPlayer.cHead; this.cFace = this.drawPlayer.cFace; this.cUnicornHorn = this.drawPlayer.cUnicornHorn; this.drawUnicornHorn = this.drawPlayer.hasUnicornHorn; Main.instance.LoadHair(this.drawPlayer.hair); this.scale = Scale; this.colorEyeWhites = Main.quickAlpha(Color.White, Alpha); this.colorEyes = Main.quickAlpha(this.drawPlayer.eyeColor, Alpha); this.colorHair = Main.quickAlpha(this.drawPlayer.GetHairColor(false), Alpha); this.colorHead = Main.quickAlpha(this.drawPlayer.skinColor, Alpha); this.colorArmorHead = Main.quickAlpha(Color.White, Alpha); this.playerEffect = SpriteEffects.None; if (this.drawPlayer.direction < 0) { this.playerEffect = SpriteEffects.FlipHorizontally; } this.headVect = new Vector2((float)this.drawPlayer.legFrame.Width * 0.5f, (float)this.drawPlayer.legFrame.Height * 0.4f); this.bodyFrameMemory = this.drawPlayer.bodyFrame; this.bodyFrameMemory.Y = 0; this.Position = Main.screenPosition; this.Position.X += X; this.Position.Y += Y; this.Position.X -= 6f; this.Position.Y -= 4f; this.Position.Y -= (float)this.drawPlayer.HeightMapOffset; if (this.drawPlayer.head > 0 && this.drawPlayer.head < 266) { Main.instance.LoadArmorHead(this.drawPlayer.head); int i = ArmorIDs.Head.Sets.FrontToBackID[this.drawPlayer.head]; if (i >= 0) { Main.instance.LoadArmorHead(i); } } if (this.drawPlayer.face > (sbyte)0 && this.drawPlayer.face < (sbyte)16) { Main.instance.LoadAccFace((int)this.drawPlayer.face); } this.helmetOffset = this.drawPlayer.GetHelmetDrawOffset(); this.drawPlayer.GetHairSettings(out this.fullHair, out this.hatHair, out this.hideHair, out bool _, out this.helmetIsOverFullHair); this.helmetIsTall = this.drawPlayer.head == 14 || this.drawPlayer.head == 56 || this.drawPlayer.head == 158; this.helmetIsNormal = !this.helmetIsTall && !this.helmetIsOverFullHair && (this.drawPlayer.head > 0 && this.drawPlayer.head < 266) && this.drawPlayer.head != 28; }