Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TorchID.cs
Go to the documentation of this file.
3
4namespace Terraria.ID;
5
6public static class TorchID
7{
8 private interface ITorchLightProvider
9 {
10 void GetRGB(out float r, out float g, out float b);
11 }
12
14 {
15 public float R;
16
17 public float G;
18
19 public float B;
20
21 public ConstantTorchLight(float Red, float Green, float Blue)
22 {
23 R = Red;
24 G = Green;
25 B = Blue;
26 }
27
28 public void GetRGB(out float r, out float g, out float b)
29 {
30 r = R;
31 g = G;
32 b = B;
33 }
34 }
35
36 [StructLayout(LayoutKind.Sequential, Size = 1)]
38 {
39 public void GetRGB(out float r, out float g, out float b)
40 {
41 r = 0.5f * Main.demonTorch + (1f - Main.demonTorch);
42 g = 0.3f;
43 b = Main.demonTorch + 0.5f * (1f - Main.demonTorch);
44 }
45 }
46
47 [StructLayout(LayoutKind.Sequential, Size = 1)]
49 {
50 public void GetRGB(out float r, out float g, out float b)
51 {
52 float num = 0.9f;
53 float num2 = 0.9f;
54 num += (float)(270 - Main.mouseTextColor) / 900f;
55 num2 += (float)(270 - Main.mouseTextColor) / 125f;
56 num = MathHelper.Clamp(num, 0f, 1f);
57 num2 = MathHelper.Clamp(num2, 0f, 1f);
58 r = num * 0.9f;
59 g = num2 * 0.55f;
60 b = num * 1.2f;
61 }
62 }
63
64 [StructLayout(LayoutKind.Sequential, Size = 1)]
66 {
67 public void GetRGB(out float r, out float g, out float b)
68 {
69 r = (float)Main.DiscoR / 255f;
70 g = (float)Main.DiscoG / 255f;
71 b = (float)Main.DiscoB / 255f;
72 }
73 }
74
75 public static int[] Dust = new int[24]
76 {
77 6, 59, 60, 61, 62, 63, 64, 65, 75, 135,
78 158, 169, 156, 234, 66, 242, 293, 294, 295, 296,
79 297, 298, 307, 310
80 };
81
82 private static ITorchLightProvider[] _lights;
83
84 public const short Torch = 0;
85
86 public const short Blue = 1;
87
88 public const short Red = 2;
89
90 public const short Green = 3;
91
92 public const short Purple = 4;
93
94 public const short White = 5;
95
96 public const short Yellow = 6;
97
98 public const short Demon = 7;
99
100 public const short Cursed = 8;
101
102 public const short Ice = 9;
103
104 public const short Orange = 10;
105
106 public const short Ichor = 11;
107
108 public const short UltraBright = 12;
109
110 public const short Bone = 13;
111
112 public const short Rainbow = 14;
113
114 public const short Pink = 15;
115
116 public const short Desert = 16;
117
118 public const short Coral = 17;
119
120 public const short Corrupt = 18;
121
122 public const short Crimson = 19;
123
124 public const short Hallowed = 20;
125
126 public const short Jungle = 21;
127
128 public const short Mushroom = 22;
129
130 public const short Shimmer = 23;
131
132 public static readonly short Count = 24;
133
134 public static void Initialize()
135 {
137 array[0] = new ConstantTorchLight(1f, 0.95f, 0.8f);
138 array[1] = new ConstantTorchLight(0f, 0.1f, 1.3f);
139 array[2] = new ConstantTorchLight(1f, 0.1f, 0.1f);
140 array[3] = new ConstantTorchLight(0f, 1f, 0.1f);
141 array[4] = new ConstantTorchLight(0.9f, 0f, 0.9f);
142 array[5] = new ConstantTorchLight(1.4f, 1.4f, 1.4f);
143 array[6] = new ConstantTorchLight(0.9f, 0.9f, 0f);
144 array[7] = default(DemonTorchLight);
145 array[8] = new ConstantTorchLight(1f, 1.6f, 0.5f);
146 array[9] = new ConstantTorchLight(0.75f, 0.85f, 1.4f);
147 array[10] = new ConstantTorchLight(1f, 0.5f, 0f);
148 array[11] = new ConstantTorchLight(1.4f, 1.4f, 0.7f);
149 array[12] = new ConstantTorchLight(0.75f, 1.3499999f, 1.5f);
150 array[13] = new ConstantTorchLight(0.95f, 0.75f, 1.3f);
151 array[14] = default(DiscoTorchLight);
152 array[15] = new ConstantTorchLight(1f, 0f, 1f);
153 array[16] = new ConstantTorchLight(1.4f, 0.85f, 0.55f);
154 array[17] = new ConstantTorchLight(0.25f, 1.3f, 0.8f);
155 array[18] = new ConstantTorchLight(0.95f, 0.4f, 1.4f);
156 array[19] = new ConstantTorchLight(1.4f, 0.7f, 0.5f);
157 array[20] = new ConstantTorchLight(1.25f, 0.6f, 1.2f);
158 array[21] = new ConstantTorchLight(0.75f, 1.45f, 0.9f);
159 array[22] = new ConstantTorchLight(0.3f, 0.78f, 1.2f);
160 array[23] = default(ShimmerTorchLight);
161 _lights = array;
162 }
163
164 public static void TorchColor(int torchID, out float R, out float G, out float B)
165 {
166 if (torchID < 0 || torchID >= _lights.Length)
167 {
168 R = (G = (B = 0f));
169 }
170 else
171 {
172 _lights[torchID].GetRGB(out R, out G, out B);
173 }
174 }
175}
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
const short Pink
Definition TorchID.cs:114
static void Initialize()
Definition TorchID.cs:134
const short Rainbow
Definition TorchID.cs:112
const short UltraBright
Definition TorchID.cs:108
static readonly short Count
Definition TorchID.cs:132
const short Ice
Definition TorchID.cs:102
const short Yellow
Definition TorchID.cs:96
const short Crimson
Definition TorchID.cs:122
const short Corrupt
Definition TorchID.cs:120
const short White
Definition TorchID.cs:94
const short Mushroom
Definition TorchID.cs:128
const short Ichor
Definition TorchID.cs:106
const short Green
Definition TorchID.cs:90
const short Purple
Definition TorchID.cs:92
const short Demon
Definition TorchID.cs:98
const short Shimmer
Definition TorchID.cs:130
static void TorchColor(int torchID, out float R, out float G, out float B)
Definition TorchID.cs:164
const short Torch
Definition TorchID.cs:84
const short Orange
Definition TorchID.cs:104
const short Blue
Definition TorchID.cs:86
const short Jungle
Definition TorchID.cs:126
const short Red
Definition TorchID.cs:88
const short Bone
Definition TorchID.cs:110
const short Cursed
Definition TorchID.cs:100
const short Coral
Definition TorchID.cs:118
static ITorchLightProvider[] _lights
Definition TorchID.cs:82
const short Hallowed
Definition TorchID.cs:124
static int DiscoR
Definition Main.cs:1062
static float demonTorch
Definition Main.cs:1330
static byte mouseTextColor
Definition Main.cs:1751
static int DiscoG
Definition Main.cs:1066
static int DiscoB
Definition Main.cs:1064
void GetRGB(out float r, out float g, out float b)
ConstantTorchLight(float Red, float Green, float Blue)
Definition TorchID.cs:21
void GetRGB(out float r, out float g, out float b)
Definition TorchID.cs:28
void GetRGB(out float r, out float g, out float b)
Definition TorchID.cs:39
void GetRGB(out float r, out float g, out float b)
Definition TorchID.cs:67
void GetRGB(out float r, out float g, out float b)
Definition TorchID.cs:50