Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PotionOfReturnGateHelper.cs
Go to the documentation of this file.
1using System;
7using Terraria.ID;
8
10
12{
13 public enum GateType
14 {
17 }
18
19 private readonly Vector2 _position;
20
21 private readonly float _opacity;
22
23 private readonly int _frameNumber;
24
25 private readonly GateType _gateType;
26
28 {
30 worldPosition.Y -= 2f;
33 int num = (int)(((float)Main.tileFrameCounter[491] + _position.X + _position.Y) % 40f) / 5;
34 if (gateType == GateType.ExitPoint)
35 {
36 num = 7 - num;
37 }
38 _frameNumber = num;
39 }
40
41 public void Update()
42 {
43 Lighting.AddLight(_position, 0.4f, 0.2f, 0.9f);
45 }
46
48 {
49 if (_gateType == GateType.EntryPoint)
50 {
51 if (Main.rand.Next(3) == 0)
52 {
53 if (Main.rand.Next(2) == 0)
54 {
55 Vector2 vector = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
56 vector *= new Vector2(0.5f, 1f);
57 Dust dust = Dust.NewDustDirect(_position - vector * 30f, 0, 0, Utils.SelectRandom<int>(Main.rand, 86, 88));
58 dust.noGravity = true;
59 dust.noLightEmittence = true;
60 dust.position = _position - vector.SafeNormalize(Vector2.Zero) * Main.rand.Next(10, 21);
61 dust.velocity = vector.RotatedBy(1.5707963705062866) * 2f;
62 dust.scale = 0.5f + Main.rand.NextFloat();
63 dust.fadeIn = 0.5f;
64 dust.customData = this;
65 dust.position += dust.velocity * 10f;
66 dust.velocity *= -1f;
67 }
68 else
69 {
70 Vector2 vector2 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
71 vector2 *= new Vector2(0.5f, 1f);
72 Dust dust2 = Dust.NewDustDirect(_position - vector2 * 30f, 0, 0, 240);
73 dust2.noGravity = true;
74 dust2.noLight = true;
75 dust2.position = _position - vector2.SafeNormalize(Vector2.Zero) * Main.rand.Next(5, 10);
76 dust2.velocity = vector2.RotatedBy(-1.5707963705062866) * 3f;
77 dust2.scale = 0.5f + Main.rand.NextFloat();
78 dust2.fadeIn = 0.5f;
79 dust2.customData = this;
80 dust2.position += dust2.velocity * 10f;
81 dust2.velocity *= -1f;
82 }
83 }
84 }
85 else if (Main.rand.Next(3) == 0)
86 {
87 if (Main.rand.Next(2) == 0)
88 {
89 Vector2 vector3 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
90 vector3 *= new Vector2(0.5f, 1f);
91 Dust dust3 = Dust.NewDustDirect(_position - vector3 * 30f, 0, 0, Utils.SelectRandom<int>(Main.rand, 86, 88));
92 dust3.noGravity = true;
93 dust3.noLightEmittence = true;
94 dust3.position = _position;
95 dust3.velocity = vector3.RotatedBy(-0.7853981852531433) * 2f;
96 dust3.scale = 0.5f + Main.rand.NextFloat();
97 dust3.fadeIn = 0.5f;
98 dust3.customData = this;
99 dust3.position += vector3 * new Vector2(20f);
100 }
101 else
102 {
103 Vector2 vector4 = Vector2.UnitY.RotatedByRandom(6.2831854820251465);
104 vector4 *= new Vector2(0.5f, 1f);
105 Dust dust4 = Dust.NewDustDirect(_position - vector4 * 30f, 0, 0, Utils.SelectRandom<int>(Main.rand, 86, 88));
106 dust4.noGravity = true;
107 dust4.noLightEmittence = true;
108 dust4.position = _position;
109 dust4.velocity = vector4.RotatedBy(-0.7853981852531433) * 2f;
110 dust4.scale = 0.5f + Main.rand.NextFloat();
111 dust4.fadeIn = 0.5f;
112 dust4.customData = this;
113 dust4.position += vector4 * new Vector2(20f);
114 }
115 }
116 }
117
119 {
120 short num = (short)((_gateType == GateType.EntryPoint) ? 183 : 184);
122 Rectangle rectangle = val.Frame(1, 8, 0, _frameNumber);
123 Color color = Lighting.GetColor(_position.ToTileCoordinates());
124 color = Color.Lerp(color, Color.White, 0.5f);
125 color *= _opacity;
126 DrawData drawData = new DrawData(val.Value, _position - Main.screenPosition, rectangle, color, 0f, rectangle.Size() / 2f, 1f, SpriteEffects.None);
128 for (float num2 = 0f; num2 < 1f; num2 += 0.34f)
129 {
131 item.color = new Color(127, 50, 127, 0) * _opacity;
132 item.scale *= 1.1f;
133 float x = (Main.GlobalTimeWrappedHourly / 5f * ((float)Math.PI * 2f)).ToRotationVector2().X;
134 item.color *= x * 0.1f + 0.3f;
135 item.position += ((Main.GlobalTimeWrappedHourly / 5f + num2) * ((float)Math.PI * 2f)).ToRotationVector2() * (x * 1f + 2f);
137 }
138 if (selectionMode != 0)
139 {
140 int num3 = (color.R + color.G + color.B) / 3;
141 if (num3 > 10)
142 {
143 Color selectionGlowColor = Colors.GetSelectionGlowColor(selectionMode == 2, num3);
144 Texture2D value = TextureAssets.Extra[242].Value;
145 Rectangle value2 = value.Frame(1, 8, 0, _frameNumber);
146 drawData = new DrawData(value, _position - Main.screenPosition, value2, selectionGlowColor, 0f, rectangle.Size() / 2f, 1f, SpriteEffects.None);
148 }
149 }
150 }
151}
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 >[] 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 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
void DrawToDrawData(List< DrawData > drawDataList, int selectionMode)
PotionOfReturnGateHelper(GateType gateType, Vector2 worldPosition, float opacity)