Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
TorchID.cs
Go to the documentation of this file.
1
using
System.Runtime.InteropServices
;
2
using
Microsoft.Xna.Framework
;
3
4
namespace
Terraria.ID
;
5
6
public
static
class
TorchID
7
{
8
private
interface
ITorchLightProvider
9
{
10
void
GetRGB
(out
float
r, out
float
g, out
float
b);
11
}
12
13
private
struct
ConstantTorchLight
:
ITorchLightProvider
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)]
37
private
struct
DemonTorchLight
:
ITorchLightProvider
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)]
48
private
struct
ShimmerTorchLight
:
ITorchLightProvider
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)]
65
private
struct
DiscoTorchLight
:
ITorchLightProvider
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
{
136
ITorchLightProvider
[] array =
new
ITorchLightProvider
[
Count
];
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
}
Microsoft.Xna.Framework.MathHelper.Clamp
static float Clamp(float value, float min, float max)
Definition
MathHelper.cs:46
Microsoft.Xna.Framework.MathHelper
Definition
MathHelper.cs:6
Terraria.Dust
Definition
Dust.cs:11
Terraria.ID.TorchID.Pink
const short Pink
Definition
TorchID.cs:114
Terraria.ID.TorchID.Initialize
static void Initialize()
Definition
TorchID.cs:134
Terraria.ID.TorchID.Rainbow
const short Rainbow
Definition
TorchID.cs:112
Terraria.ID.TorchID.UltraBright
const short UltraBright
Definition
TorchID.cs:108
Terraria.ID.TorchID.Count
static readonly short Count
Definition
TorchID.cs:132
Terraria.ID.TorchID.Ice
const short Ice
Definition
TorchID.cs:102
Terraria.ID.TorchID.Yellow
const short Yellow
Definition
TorchID.cs:96
Terraria.ID.TorchID.Crimson
const short Crimson
Definition
TorchID.cs:122
Terraria.ID.TorchID.Corrupt
const short Corrupt
Definition
TorchID.cs:120
Terraria.ID.TorchID.White
const short White
Definition
TorchID.cs:94
Terraria.ID.TorchID.Mushroom
const short Mushroom
Definition
TorchID.cs:128
Terraria.ID.TorchID.Ichor
const short Ichor
Definition
TorchID.cs:106
Terraria.ID.TorchID.Green
const short Green
Definition
TorchID.cs:90
Terraria.ID.TorchID.Purple
const short Purple
Definition
TorchID.cs:92
Terraria.ID.TorchID.Demon
const short Demon
Definition
TorchID.cs:98
Terraria.ID.TorchID.Shimmer
const short Shimmer
Definition
TorchID.cs:130
Terraria.ID.TorchID.TorchColor
static void TorchColor(int torchID, out float R, out float G, out float B)
Definition
TorchID.cs:164
Terraria.ID.TorchID.Torch
const short Torch
Definition
TorchID.cs:84
Terraria.ID.TorchID.Orange
const short Orange
Definition
TorchID.cs:104
Terraria.ID.TorchID.Blue
const short Blue
Definition
TorchID.cs:86
Terraria.ID.TorchID.Jungle
const short Jungle
Definition
TorchID.cs:126
Terraria.ID.TorchID.Red
const short Red
Definition
TorchID.cs:88
Terraria.ID.TorchID.Bone
const short Bone
Definition
TorchID.cs:110
Terraria.ID.TorchID.Cursed
const short Cursed
Definition
TorchID.cs:100
Terraria.ID.TorchID.Coral
const short Coral
Definition
TorchID.cs:118
Terraria.ID.TorchID._lights
static ITorchLightProvider[] _lights
Definition
TorchID.cs:82
Terraria.ID.TorchID.Hallowed
const short Hallowed
Definition
TorchID.cs:124
Terraria.ID.TorchID
Definition
TorchID.cs:7
Terraria.Main.DiscoR
static int DiscoR
Definition
Main.cs:1062
Terraria.Main.demonTorch
static float demonTorch
Definition
Main.cs:1330
Terraria.Main.mouseTextColor
static byte mouseTextColor
Definition
Main.cs:1751
Terraria.Main.DiscoG
static int DiscoG
Definition
Main.cs:1066
Terraria.Main.DiscoB
static int DiscoB
Definition
Main.cs:1064
Terraria.Main
Definition
Main.cs:79
Terraria.ID.TorchID.ITorchLightProvider.GetRGB
void GetRGB(out float r, out float g, out float b)
Terraria.ID.TorchID.ITorchLightProvider
Definition
TorchID.cs:9
Microsoft.Xna.Framework
Definition
AlphaTestEffect.cs:1
System.Runtime.InteropServices.LayoutKind
LayoutKind
Definition
LayoutKind.cs:4
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
Terraria.ID
Definition
AchievementHelperID.cs:1
Terraria.ID.TorchID.ConstantTorchLight.R
float R
Definition
TorchID.cs:15
Terraria.ID.TorchID.ConstantTorchLight.G
float G
Definition
TorchID.cs:17
Terraria.ID.TorchID.ConstantTorchLight.ConstantTorchLight
ConstantTorchLight(float Red, float Green, float Blue)
Definition
TorchID.cs:21
Terraria.ID.TorchID.ConstantTorchLight.GetRGB
void GetRGB(out float r, out float g, out float b)
Definition
TorchID.cs:28
Terraria.ID.TorchID.ConstantTorchLight.B
float B
Definition
TorchID.cs:19
Terraria.ID.TorchID.ConstantTorchLight
Definition
TorchID.cs:14
Terraria.ID.TorchID.DemonTorchLight.GetRGB
void GetRGB(out float r, out float g, out float b)
Definition
TorchID.cs:39
Terraria.ID.TorchID.DemonTorchLight
Definition
TorchID.cs:38
Terraria.ID.TorchID.DiscoTorchLight.GetRGB
void GetRGB(out float r, out float g, out float b)
Definition
TorchID.cs:67
Terraria.ID.TorchID.DiscoTorchLight
Definition
TorchID.cs:66
Terraria.ID.TorchID.ShimmerTorchLight.GetRGB
void GetRGB(out float r, out float g, out float b)
Definition
TorchID.cs:50
Terraria.ID.TorchID.ShimmerTorchLight
Definition
TorchID.cs:49
source
Terraria.ID
TorchID.cs
Generated by
1.10.0