Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PrettySparkleParticle.cs
Go to the documentation of this file.
1using System;
5
7
9{
10 public float FadeInNormalizedTime = 0.05f;
11
12 public float FadeOutNormalizedTime = 0.9f;
13
14 public float TimeToLive = 60f;
15
17
18 public float Opacity;
19
20 public float AdditiveAmount = 1f;
21
22 public float FadeInEnd = 20f;
23
24 public float FadeOutStart = 30f;
25
26 public float FadeOutEnd = 45f;
27
28 public bool DrawHorizontalAxis = true;
29
30 public bool DrawVerticalAxis = true;
31
32 private float _timeSinceSpawn;
33
34 public override void FetchFromPool()
35 {
36 base.FetchFromPool();
38 _timeSinceSpawn = 0f;
39 Opacity = 0f;
42 TimeToLive = 60f;
43 AdditiveAmount = 1f;
44 FadeInEnd = 20f;
45 FadeOutStart = 30f;
46 FadeOutEnd = 45f;
48 }
49
50 public override void Update(ref ParticleRendererSettings settings)
51 {
52 base.Update(ref settings);
53 _timeSinceSpawn += 1f;
56 {
57 base.ShouldBeRemovedFromRenderer = true;
58 }
59 }
60
61 public override void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
62 {
63 Color color = Color.White * Opacity * 0.9f;
64 color.A /= 2;
66 Color color2 = ColorTint * Opacity * 0.5f;
67 color2.A = (byte)((float)(int)color2.A * (1f - AdditiveAmount));
68 Vector2 origin = value.Size() / 2f;
69 Color color3 = color * 0.5f;
70 float t = _timeSinceSpawn / TimeToLive * 60f;
71 float num = Utils.GetLerpValue(0f, FadeInEnd, t, clamped: true) * Utils.GetLerpValue(FadeOutEnd, FadeOutStart, t, clamped: true);
72 Vector2 vector = new Vector2(0.3f, 2f) * num * Scale;
73 Vector2 vector2 = new Vector2(0.3f, 1f) * num * Scale;
74 color2 *= num;
75 color3 *= num;
76 Vector2 position = settings.AnchorPosition + LocalPosition;
77 SpriteEffects effects = SpriteEffects.None;
79 {
80 spritebatch.Draw(value, position, null, color2, (float)Math.PI / 2f + Rotation, origin, vector, effects, 0f);
81 }
83 {
84 spritebatch.Draw(value, position, null, color2, 0f + Rotation, origin, vector2, effects, 0f);
85 }
87 {
88 spritebatch.Draw(value, position, null, color3, (float)Math.PI / 2f + Rotation, origin, vector * 0.6f, effects, 0f);
89 }
91 {
92 spritebatch.Draw(value, position, null, color3, 0f + Rotation, origin, vector2 * 0.6f, effects, 0f);
93 }
94 }
95}
void Draw(Texture2D texture, Vector2 position, Color color)
const double PI
Definition Math.cs:16
static Asset< Texture2D >[] Extra
override void Draw(ref ParticleRendererSettings settings, SpriteBatch spritebatch)
override void Update(ref ParticleRendererSettings settings)
static float GetLerpValue(float from, float to, float t, bool clamped=false)
Definition Utils.cs:203
static Color Transparent
Definition Color.cs:76