Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MagicMissileDrawer.cs
Go to the documentation of this file.
4
5namespace Terraria.Graphics;
6
7[StructLayout(LayoutKind.Sequential, Size = 1)]
8public struct MagicMissileDrawer
9{
10 private static VertexStrip _vertexStrip = new VertexStrip();
11
12 public void Draw(Projectile proj)
13 {
14 MiscShaderData miscShaderData = GameShaders.Misc["MagicMissile"];
15 miscShaderData.UseSaturation(-2.8f);
16 miscShaderData.UseOpacity(2f);
17 miscShaderData.Apply();
18 _vertexStrip.PrepareStripWithProceduralPadding(proj.oldPos, proj.oldRot, StripColors, StripWidth, -Main.screenPosition + proj.Size / 2f);
19 _vertexStrip.DrawTrail();
20 Main.pixelShader.CurrentTechnique.Passes[0].Apply();
21 }
22
23 private Color StripColors(float progressOnStrip)
24 {
25 Color result = Color.Lerp(Color.White, Color.Violet, Utils.GetLerpValue(0f, 0.7f, progressOnStrip, clamped: true)) * (1f - Utils.GetLerpValue(0f, 0.98f, progressOnStrip));
26 result.A /= 2;
27 return result;
28 }
29
30 private float StripWidth(float progressOnStrip)
31 {
32 return MathHelper.Lerp(26f, 32f, Utils.GetLerpValue(0f, 0.2f, progressOnStrip, clamped: true)) * Utils.GetLerpValue(0f, 0.07f, progressOnStrip, clamped: true);
33 }
34}
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)