Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
RainbowRodDrawer.cs
Go to the documentation of this file.
1
using
System.Runtime.InteropServices
;
2
using
Microsoft.Xna.Framework
;
3
using
Terraria.Graphics.Shaders
;
4
5
namespace
Terraria.Graphics
;
6
7
[StructLayout(
LayoutKind
.Sequential, Size = 1)]
8
public
struct
RainbowRodDrawer
9
{
10
private
static
VertexStrip
_vertexStrip
=
new
VertexStrip
();
11
12
public
void
Draw
(
Projectile
proj)
13
{
14
MiscShaderData
miscShaderData =
GameShaders
.
Misc
[
"RainbowRod"
];
15
miscShaderData.
UseSaturation
(-2.8f);
16
miscShaderData.
UseOpacity
(4f);
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
value =
Main
.
hslToRgb
((progressOnStrip * 1.6f -
Main
.
GlobalTimeWrappedHourly
) % 1f, 1f, 0.5f);
26
Color
result =
Color
.
Lerp
(
Color
.
White
, value,
Utils
.
GetLerpValue
(-0.2f, 0.5f, progressOnStrip, clamped:
true
)) * (1f -
Utils
.
GetLerpValue
(0f, 0.98f, progressOnStrip));
27
result.A = 0;
28
return
result;
29
}
30
31
private
float
StripWidth
(
float
progressOnStrip)
32
{
33
float
num = 1f;
34
float
lerpValue =
Utils
.
GetLerpValue
(0f, 0.2f, progressOnStrip, clamped:
true
);
35
num *= 1f - (1f - lerpValue) * (1f - lerpValue);
36
return
MathHelper
.
Lerp
(0f, 32f, num);
37
}
38
}
Microsoft.Xna.Framework.MathHelper.Lerp
static float Lerp(float value1, float value2, float amount)
Definition
MathHelper.cs:53
Microsoft.Xna.Framework.MathHelper
Definition
MathHelper.cs:6
Terraria.Entity.Size
Vector2 Size
Definition
Entity.cs:151
Terraria.Graphics.Shaders.GameShaders.Misc
static Dictionary< string, MiscShaderData > Misc
Definition
GameShaders.cs:11
Terraria.Graphics.Shaders.GameShaders
Definition
GameShaders.cs:6
Terraria.Graphics.Shaders.MiscShaderData.Apply
virtual void Apply(DrawData? drawData=null)
Definition
MiscShaderData.cs:36
Terraria.Graphics.Shaders.MiscShaderData.UseSaturation
MiscShaderData UseSaturation(float saturation)
Definition
MiscShaderData.cs:160
Terraria.Graphics.Shaders.MiscShaderData.UseOpacity
MiscShaderData UseOpacity(float alpha)
Definition
MiscShaderData.cs:132
Terraria.Graphics.Shaders.MiscShaderData
Definition
MiscShaderData.cs:10
Terraria.Graphics.VertexStrip
Definition
VertexStrip.cs:9
Terraria.Main.pixelShader
static Effect pixelShader
Definition
Main.cs:2764
Terraria.Main.screenPosition
static Vector2 screenPosition
Definition
Main.cs:1715
Terraria.Main.hslToRgb
static Microsoft.Xna.Framework.Color hslToRgb(Vector3 hslVector)
Definition
Main.cs:44913
Terraria.Main.GlobalTimeWrappedHourly
static float GlobalTimeWrappedHourly
Definition
Main.cs:405
Terraria.Main
Definition
Main.cs:79
Terraria.Projectile.oldRot
float[] oldRot
Definition
Projectile.cs:170
Terraria.Projectile.oldPos
Vector2[] oldPos
Definition
Projectile.cs:168
Terraria.Projectile
Definition
Projectile.cs:31
Terraria.Utils.GetLerpValue
static float GetLerpValue(float from, float to, float t, bool clamped=false)
Definition
Utils.cs:203
Terraria.Utils
Definition
Utils.cs:29
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
System.Runtime.InteropServices.LayoutKind
LayoutKind
Definition
LayoutKind.cs:4
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
Terraria.Graphics.Shaders
Definition
ArmorShaderData.cs:6
Terraria.Graphics
Definition
CameraInfo.cs:3
Microsoft.Xna.Framework.Color.Lerp
static Color Lerp(Color value1, Color value2, float amount)
Definition
Color.cs:491
Microsoft.Xna.Framework.Color.White
static Color White
Definition
Color.cs:350
Microsoft.Xna.Framework.Color
Definition
Color.cs:12
Terraria.Graphics.RainbowRodDrawer.Draw
void Draw(Projectile proj)
Definition
RainbowRodDrawer.cs:12
Terraria.Graphics.RainbowRodDrawer.StripColors
Color StripColors(float progressOnStrip)
Definition
RainbowRodDrawer.cs:23
Terraria.Graphics.RainbowRodDrawer._vertexStrip
static VertexStrip _vertexStrip
Definition
RainbowRodDrawer.cs:10
Terraria.Graphics.RainbowRodDrawer.StripWidth
float StripWidth(float progressOnStrip)
Definition
RainbowRodDrawer.cs:31
Terraria.Graphics.RainbowRodDrawer
Definition
RainbowRodDrawer.cs:9
source
Terraria.Graphics
RainbowRodDrawer.cs
Generated by
1.10.0