Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
VoidLensHelper.cs
Go to the documentation of this file.
1using System;
7using Terraria.ID;
8
10
11public struct VoidLensHelper
12{
13 private readonly Vector2 _position;
14
15 private readonly float _opacity;
16
17 private readonly int _frameNumber;
18
20 {
21 _position = proj.Center;
22 _opacity = proj.Opacity;
23 _frameNumber = proj.frame;
24 }
25
27 {
28 worldPosition.Y -= 2f;
31 _frameNumber = (int)(((float)Main.tileFrameCounter[491] + _position.X + _position.Y) % 40f) / 5;
32 }
33
34 public void Update()
35 {
36 Lighting.AddLight(_position, 0.4f, 0.2f, 0.9f);
38 }
39
40 public void SpawnVoidLensDust()
41 {
42 if (Main.rand.Next(3) == 0)
43 {
44 if (Main.rand.Next(2) == 0)
45 {
46 Vector2 vector = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
47 vector *= new Vector2(0.5f, 1f);
48 Dust dust = Dust.NewDustDirect(_position - vector * 30f, 0, 0, Utils.SelectRandom<int>(Main.rand, 86, 88));
49 dust.noGravity = true;
50 dust.noLightEmittence = true;
51 dust.position = _position - vector.SafeNormalize(Vector2.Zero) * Main.rand.Next(10, 21);
52 dust.velocity = vector.RotatedBy(1.5707963705062866) * 2f;
53 dust.scale = 0.5f + Main.rand.NextFloat();
54 dust.fadeIn = 0.5f;
55 dust.customData = this;
56 dust.position += dust.velocity * 10f;
57 dust.velocity *= -1f;
58 }
59 else
60 {
61 Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
62 vector2 *= new Vector2(0.5f, 1f);
63 Dust dust2 = Dust.NewDustDirect(_position - vector2 * 30f, 0, 0, Utils.SelectRandom<int>(Main.rand, 86, 88));
64 dust2.noGravity = true;
65 dust2.noLightEmittence = true;
66 dust2.position = _position - vector2.SafeNormalize(Vector2.Zero) * Main.rand.Next(5, 10);
67 dust2.velocity = vector2.RotatedBy(-1.5707963705062866) * 3f;
68 dust2.scale = 0.5f + Main.rand.NextFloat();
69 dust2.fadeIn = 0.5f;
70 dust2.customData = this;
71 dust2.position += dust2.velocity * 10f;
72 dust2.velocity *= -1f;
73 }
74 }
75 }
76
78 {
79 Main.instance.LoadProjectile(734);
81 Rectangle rectangle = val.Frame(1, 8, 0, _frameNumber);
82 Color color = Lighting.GetColor(_position.ToTileCoordinates());
83 color = Color.Lerp(color, Color.White, 0.5f);
84 color *= _opacity;
85 DrawData drawData = new DrawData(val.Value, _position - Main.screenPosition, rectangle, color, 0f, rectangle.Size() / 2f, 1f, SpriteEffects.None);
87 for (float num = 0f; num < 1f; num += 0.34f)
88 {
90 item.color = new Color(127, 50, 127, 0) * _opacity;
91 item.scale *= 1.1f;
92 float x = (Main.GlobalTimeWrappedHourly / 5f * ((float)Math.PI * 2f)).ToRotationVector2().X;
93 item.color *= x * 0.1f + 0.3f;
94 item.position += ((Main.GlobalTimeWrappedHourly / 5f + num) * ((float)Math.PI * 2f)).ToRotationVector2() * (x * 1f + 2f);
96 }
97 if (selectionMode != 0)
98 {
99 int num2 = (color.R + color.G + color.B) / 3;
100 if (num2 > 10)
101 {
102 Color selectionGlowColor = Colors.GetSelectionGlowColor(selectionMode == 2, num2);
103 drawData = new DrawData(TextureAssets.Extra[93].Value, _position - Main.screenPosition, rectangle, selectionGlowColor, 0f, rectangle.Size() / 2f, 1f, SpriteEffects.None);
105 }
106 }
107 }
108}
void Add(TKey key, TValue value)
const double PI
Definition Math.cs:16
static Dust NewDustDirect(Vector2 Position, int Width, int Height, int Type, float SpeedX=0f, float SpeedY=0f, int Alpha=0, Color newColor=default(Color), float Scale=1f)
Definition Dust.cs:63
static Asset< Texture2D >[] Projectile
static Asset< Texture2D >[] Extra
static Color GetSelectionGlowColor(bool isTileSelected, int averageTileLighting)
Definition Colors.cs:127
static Color GetColor(Point tileCoords)
Definition Lighting.cs:182
static void AddLight(Vector2 position, Vector3 rgb)
Definition Lighting.cs:137
static Main instance
Definition Main.cs:283
static Vector2 screenPosition
Definition Main.cs:1715
static int[] tileFrameCounter
Definition Main.cs:1659
static UnifiedRandom rand
Definition Main.cs:1387
static Color Lerp(Color value1, Color value2, float amount)
Definition Color.cs:491
VoidLensHelper(Vector2 worldPosition, float opacity)
void DrawToDrawData(List< DrawData > drawDataList, int selectionMode)