Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FlameLashDrawer.cs
Go to the documentation of this file.
3
4namespace Terraria.Graphics;
5
6public struct FlameLashDrawer
7{
8 private static VertexStrip _vertexStrip = new VertexStrip();
9
10 private float transitToDark;
11
12 public void Draw(Projectile proj)
13 {
14 transitToDark = Utils.GetLerpValue(0f, 6f, proj.localAI[0], clamped: true);
15 MiscShaderData miscShaderData = GameShaders.Misc["FlameLash"];
16 miscShaderData.UseSaturation(-2f);
17 miscShaderData.UseOpacity(MathHelper.Lerp(4f, 8f, transitToDark));
18 miscShaderData.Apply();
19 _vertexStrip.PrepareStripWithProceduralPadding(proj.oldPos, proj.oldRot, StripColors, StripWidth, -Main.screenPosition + proj.Size / 2f);
20 _vertexStrip.DrawTrail();
21 Main.pixelShader.CurrentTechnique.Passes[0].Apply();
22 }
23
24 private Color StripColors(float progressOnStrip)
25 {
26 float lerpValue = Utils.GetLerpValue(0f - 0.1f * transitToDark, 0.7f - 0.2f * transitToDark, progressOnStrip, clamped: true);
27 Color result = Color.Lerp(Color.Lerp(Color.White, Color.Orange, transitToDark * 0.5f), Color.Red, lerpValue) * (1f - Utils.GetLerpValue(0f, 0.98f, progressOnStrip));
28 result.A /= 8;
29 return result;
30 }
31
32 private float StripWidth(float progressOnStrip)
33 {
34 float lerpValue = Utils.GetLerpValue(0f, 0.06f + transitToDark * 0.01f, progressOnStrip, clamped: true);
35 lerpValue = 1f - (1f - lerpValue) * (1f - lerpValue);
36 return MathHelper.Lerp(24f + transitToDark * 16f, 8f, Utils.GetLerpValue(0f, 1f, progressOnStrip, clamped: true)) * lerpValue;
37 }
38}
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
Vector2 Size
Definition Entity.cs:151
static Dictionary< string, MiscShaderData > Misc
virtual void Apply(DrawData? drawData=null)
MiscShaderData UseSaturation(float saturation)
MiscShaderData UseOpacity(float alpha)
static Effect pixelShader
Definition Main.cs:2764
static Vector2 screenPosition
Definition Main.cs:1715
static float GetLerpValue(float from, float to, float t, bool clamped=false)
Definition Utils.cs:203
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491
Color StripColors(float progressOnStrip)
float StripWidth(float progressOnStrip)