Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DyeInitializer.cs
Go to the documentation of this file.
1using System;
6using Terraria.ID;
7
9
10public static class DyeInitializer
11{
12 private static void LoadBasicColorDye(int baseDyeItem, int blackDyeItem, int brightDyeItem, int silverDyeItem, float r, float g, float b, float saturation = 1f, int oldShader = 1)
13 {
14 Ref<Effect> pixelShaderRef = Main.PixelShaderRef;
15 GameShaders.Armor.BindShader(baseDyeItem, new ArmorShaderData(pixelShaderRef, "ArmorColored")).UseColor(r, g, b).UseSaturation(saturation);
16 GameShaders.Armor.BindShader(blackDyeItem, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndBlack")).UseColor(r, g, b).UseSaturation(saturation);
17 GameShaders.Armor.BindShader(brightDyeItem, new ArmorShaderData(pixelShaderRef, "ArmorColored")).UseColor(r * 0.5f + 0.5f, g * 0.5f + 0.5f, b * 0.5f + 0.5f).UseSaturation(saturation);
18 GameShaders.Armor.BindShader(silverDyeItem, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndSilverTrim")).UseColor(r, g, b).UseSaturation(saturation);
19 }
20
21 private static void LoadBasicColorDye(int baseDyeItem, float r, float g, float b, float saturation = 1f, int oldShader = 1)
22 {
23 LoadBasicColorDye(baseDyeItem, baseDyeItem + 12, baseDyeItem + 31, baseDyeItem + 44, r, g, b, saturation, oldShader);
24 }
25
26 private static void LoadBasicColorDyes()
27 {
28 LoadBasicColorDye(1007, 1f, 0f, 0f, 1.2f);
29 LoadBasicColorDye(1008, 1f, 0.5f, 0f, 1.2f, 2);
30 LoadBasicColorDye(1009, 1f, 1f, 0f, 1.2f, 3);
31 LoadBasicColorDye(1010, 0.5f, 1f, 0f, 1.2f, 4);
32 LoadBasicColorDye(1011, 0f, 1f, 0f, 1.2f, 5);
33 LoadBasicColorDye(1012, 0f, 1f, 0.5f, 1.2f, 6);
34 LoadBasicColorDye(1013, 0f, 1f, 1f, 1.2f, 7);
35 LoadBasicColorDye(1014, 0.2f, 0.5f, 1f, 1.2f, 8);
36 LoadBasicColorDye(1015, 0f, 0f, 1f, 1.2f, 9);
37 LoadBasicColorDye(1016, 0.5f, 0f, 1f, 1.2f, 10);
38 LoadBasicColorDye(1017, 1f, 0f, 1f, 1.2f, 11);
39 LoadBasicColorDye(1018, 1f, 0.1f, 0.5f, 1.3f, 12);
40 LoadBasicColorDye(2874, 2875, 2876, 2877, 0.4f, 0.2f, 0f);
41 }
42
43 private static void LoadArmorDyes()
44 {
45 Ref<Effect> pixelShaderRef = Main.PixelShaderRef;
47 GameShaders.Armor.BindShader(1050, new ArmorShaderData(pixelShaderRef, "ArmorBrightnessColored")).UseColor(0.6f, 0.6f, 0.6f);
48 GameShaders.Armor.BindShader(1037, new ArmorShaderData(pixelShaderRef, "ArmorBrightnessColored")).UseColor(1f, 1f, 1f);
49 GameShaders.Armor.BindShader(3558, new ArmorShaderData(pixelShaderRef, "ArmorBrightnessColored")).UseColor(1.5f, 1.5f, 1.5f);
50 GameShaders.Armor.BindShader(2871, new ArmorShaderData(pixelShaderRef, "ArmorBrightnessColored")).UseColor(0.05f, 0.05f, 0.05f);
51 GameShaders.Armor.BindShader(3559, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndBlack")).UseColor(1f, 1f, 1f).UseSaturation(1.2f);
52 GameShaders.Armor.BindShader(1031, new ArmorShaderData(pixelShaderRef, "ArmorColoredGradient")).UseColor(1f, 0f, 0f).UseSecondaryColor(1f, 1f, 0f)
53 .UseSaturation(1.2f);
54 GameShaders.Armor.BindShader(1032, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndBlackGradient")).UseColor(1f, 0f, 0f).UseSecondaryColor(1f, 1f, 0f)
55 .UseSaturation(1.5f);
56 GameShaders.Armor.BindShader(3550, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndSilverTrimGradient")).UseColor(1f, 0f, 0f).UseSecondaryColor(1f, 1f, 0f)
57 .UseSaturation(1.5f);
58 GameShaders.Armor.BindShader(1063, new ArmorShaderData(pixelShaderRef, "ArmorBrightnessGradient")).UseColor(1f, 0f, 0f).UseSecondaryColor(1f, 1f, 0f);
59 GameShaders.Armor.BindShader(1035, new ArmorShaderData(pixelShaderRef, "ArmorColoredGradient")).UseColor(0f, 0f, 1f).UseSecondaryColor(0f, 1f, 1f)
60 .UseSaturation(1.2f);
61 GameShaders.Armor.BindShader(1036, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndBlackGradient")).UseColor(0f, 0f, 1f).UseSecondaryColor(0f, 1f, 1f)
62 .UseSaturation(1.5f);
63 GameShaders.Armor.BindShader(3552, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndSilverTrimGradient")).UseColor(0f, 0f, 1f).UseSecondaryColor(0f, 1f, 1f)
64 .UseSaturation(1.5f);
65 GameShaders.Armor.BindShader(1065, new ArmorShaderData(pixelShaderRef, "ArmorBrightnessGradient")).UseColor(0f, 0f, 1f).UseSecondaryColor(0f, 1f, 1f);
66 GameShaders.Armor.BindShader(1033, new ArmorShaderData(pixelShaderRef, "ArmorColoredGradient")).UseColor(0f, 1f, 0f).UseSecondaryColor(1f, 1f, 0f)
67 .UseSaturation(1.2f);
68 GameShaders.Armor.BindShader(1034, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndBlackGradient")).UseColor(0f, 1f, 0f).UseSecondaryColor(1f, 1f, 0f)
69 .UseSaturation(1.5f);
70 GameShaders.Armor.BindShader(3551, new ArmorShaderData(pixelShaderRef, "ArmorColoredAndSilverTrimGradient")).UseColor(0f, 1f, 0f).UseSecondaryColor(1f, 1f, 0f)
71 .UseSaturation(1.5f);
72 GameShaders.Armor.BindShader(1064, new ArmorShaderData(pixelShaderRef, "ArmorBrightnessGradient")).UseColor(0f, 1f, 0f).UseSecondaryColor(1f, 1f, 0f);
73 GameShaders.Armor.BindShader(1068, new ArmorShaderData(pixelShaderRef, "ArmorColoredGradient")).UseColor(0.5f, 1f, 0f).UseSecondaryColor(1f, 0.5f, 0f)
74 .UseSaturation(1.5f);
75 GameShaders.Armor.BindShader(1069, new ArmorShaderData(pixelShaderRef, "ArmorColoredGradient")).UseColor(0f, 1f, 0.5f).UseSecondaryColor(0f, 0.5f, 1f)
76 .UseSaturation(1.5f);
77 GameShaders.Armor.BindShader(1070, new ArmorShaderData(pixelShaderRef, "ArmorColoredGradient")).UseColor(1f, 0f, 0.5f).UseSecondaryColor(0.5f, 0f, 1f)
78 .UseSaturation(1.5f);
79 GameShaders.Armor.BindShader(1066, new ArmorShaderData(pixelShaderRef, "ArmorColoredRainbow"));
80 GameShaders.Armor.BindShader(1067, new ArmorShaderData(pixelShaderRef, "ArmorBrightnessRainbow"));
81 GameShaders.Armor.BindShader(3556, new ArmorShaderData(pixelShaderRef, "ArmorMidnightRainbow"));
82 GameShaders.Armor.BindShader(2869, new ArmorShaderData(pixelShaderRef, "ArmorLivingFlame")).UseColor(1f, 0.9f, 0f).UseSecondaryColor(1f, 0.2f, 0f);
83 GameShaders.Armor.BindShader(2870, new ArmorShaderData(pixelShaderRef, "ArmorLivingRainbow"));
84 GameShaders.Armor.BindShader(2873, new ArmorShaderData(pixelShaderRef, "ArmorLivingOcean"));
85 GameShaders.Armor.BindShader(3026, new ReflectiveArmorShaderData(pixelShaderRef, "ArmorReflectiveColor")).UseColor(1f, 1f, 1f);
86 GameShaders.Armor.BindShader(3027, new ReflectiveArmorShaderData(pixelShaderRef, "ArmorReflectiveColor")).UseColor(1.5f, 1.2f, 0.5f);
87 GameShaders.Armor.BindShader(3553, new ReflectiveArmorShaderData(pixelShaderRef, "ArmorReflectiveColor")).UseColor(1.35f, 0.7f, 0.4f);
88 GameShaders.Armor.BindShader(3554, new ReflectiveArmorShaderData(pixelShaderRef, "ArmorReflectiveColor")).UseColor(0.25f, 0f, 0.7f);
89 GameShaders.Armor.BindShader(3555, new ReflectiveArmorShaderData(pixelShaderRef, "ArmorReflectiveColor")).UseColor(0.4f, 0.4f, 0.4f);
90 GameShaders.Armor.BindShader(3190, new ReflectiveArmorShaderData(pixelShaderRef, "ArmorReflective"));
91 GameShaders.Armor.BindShader(1969, new TeamArmorShaderData(pixelShaderRef, "ArmorColored"));
92 GameShaders.Armor.BindShader(2864, new ArmorShaderData(pixelShaderRef, "ArmorMartian")).UseColor(0f, 2f, 3f);
93 GameShaders.Armor.BindShader(2872, new ArmorShaderData(pixelShaderRef, "ArmorInvert"));
94 GameShaders.Armor.BindShader(2878, new ArmorShaderData(pixelShaderRef, "ArmorWisp")).UseColor(0.7f, 1f, 0.9f).UseSecondaryColor(0.35f, 0.85f, 0.8f);
95 GameShaders.Armor.BindShader(2879, new ArmorShaderData(pixelShaderRef, "ArmorWisp")).UseColor(1f, 1.2f, 0f).UseSecondaryColor(1f, 0.6f, 0.3f);
96 GameShaders.Armor.BindShader(2885, new ArmorShaderData(pixelShaderRef, "ArmorWisp")).UseColor(1.2f, 0.8f, 0f).UseSecondaryColor(0.8f, 0.2f, 0f);
97 GameShaders.Armor.BindShader(2884, new ArmorShaderData(pixelShaderRef, "ArmorWisp")).UseColor(1f, 0f, 1f).UseSecondaryColor(1f, 0.3f, 0.6f);
98 GameShaders.Armor.BindShader(2883, new ArmorShaderData(pixelShaderRef, "ArmorHighContrastGlow")).UseColor(0f, 1f, 0f);
99 GameShaders.Armor.BindShader(3025, new ArmorShaderData(pixelShaderRef, "ArmorFlow")).UseColor(1f, 0.5f, 1f).UseSecondaryColor(0.6f, 0.1f, 1f);
100 GameShaders.Armor.BindShader(3039, new TwilightDyeShaderData(pixelShaderRef, "ArmorTwilight")).UseImage("Images/Misc/noise").UseColor(0.5f, 0.1f, 1f);
101 GameShaders.Armor.BindShader(3040, new ArmorShaderData(pixelShaderRef, "ArmorAcid")).UseColor(0.5f, 1f, 0.3f);
102 GameShaders.Armor.BindShader(3041, new ArmorShaderData(pixelShaderRef, "ArmorMushroom")).UseColor(0.05f, 0.2f, 1f);
103 GameShaders.Armor.BindShader(3042, new ArmorShaderData(pixelShaderRef, "ArmorPhase")).UseImage("Images/Misc/noise").UseColor(0.4f, 0.2f, 1.5f);
104 GameShaders.Armor.BindShader(3560, new ArmorShaderData(pixelShaderRef, "ArmorAcid")).UseColor(0.9f, 0.2f, 0.2f);
105 GameShaders.Armor.BindShader(3561, new ArmorShaderData(pixelShaderRef, "ArmorGel")).UseImage("Images/Misc/noise").UseColor(0.4f, 0.7f, 1.4f)
106 .UseSecondaryColor(0f, 0f, 0.1f);
107 GameShaders.Armor.BindShader(3562, new ArmorShaderData(pixelShaderRef, "ArmorGel")).UseImage("Images/Misc/noise").UseColor(1.4f, 0.75f, 1f)
108 .UseSecondaryColor(0.45f, 0.1f, 0.3f);
109 GameShaders.Armor.BindShader(3024, new ArmorShaderData(pixelShaderRef, "ArmorGel")).UseImage("Images/Misc/noise").UseColor(-0.5f, -1f, 0f)
110 .UseSecondaryColor(1.5f, 1f, 2.2f);
111 GameShaders.Armor.BindShader(4663, new ArmorShaderData(pixelShaderRef, "ArmorGel")).UseImage("Images/Misc/noise").UseColor(2.6f, 0.6f, 0.6f)
112 .UseSecondaryColor(0.2f, -0.2f, -0.2f);
113 GameShaders.Armor.BindShader(4662, new ArmorShaderData(pixelShaderRef, "ArmorFog")).UseImage("Images/Misc/noise").UseColor(0.95f, 0.95f, 0.95f)
114 .UseSecondaryColor(0.3f, 0.3f, 0.3f);
115 GameShaders.Armor.BindShader(4778, new ArmorShaderData(pixelShaderRef, "ArmorHallowBoss")).UseImage("Images/Extra_" + (short)156);
116 GameShaders.Armor.BindShader(3534, new ArmorShaderData(pixelShaderRef, "ArmorMirage"));
117 GameShaders.Armor.BindShader(3028, new ArmorShaderData(pixelShaderRef, "ArmorAcid")).UseColor(0.5f, 0.7f, 1.5f);
118 GameShaders.Armor.BindShader(3557, new ArmorShaderData(pixelShaderRef, "ArmorPolarized"));
119 GameShaders.Armor.BindShader(3978, new ArmorShaderData(pixelShaderRef, "ColorOnly"));
120 GameShaders.Armor.BindShader(3038, new ArmorShaderData(pixelShaderRef, "ArmorHades")).UseColor(0.5f, 0.7f, 1.3f).UseSecondaryColor(0.5f, 0.7f, 1.3f);
121 GameShaders.Armor.BindShader(3600, new ArmorShaderData(pixelShaderRef, "ArmorHades")).UseColor(0.7f, 0.4f, 1.5f).UseSecondaryColor(0.7f, 0.4f, 1.5f);
122 GameShaders.Armor.BindShader(3597, new ArmorShaderData(pixelShaderRef, "ArmorHades")).UseColor(1.5f, 0.6f, 0.4f).UseSecondaryColor(1.5f, 0.6f, 0.4f);
123 GameShaders.Armor.BindShader(3598, new ArmorShaderData(pixelShaderRef, "ArmorHades")).UseColor(0.1f, 0.1f, 0.1f).UseSecondaryColor(0.4f, 0.05f, 0.025f);
124 GameShaders.Armor.BindShader(3599, new ArmorShaderData(pixelShaderRef, "ArmorLoki")).UseColor(0.1f, 0.1f, 0.1f);
125 GameShaders.Armor.BindShader(3533, new ArmorShaderData(pixelShaderRef, "ArmorShiftingSands")).UseImage("Images/Misc/noise").UseColor(1.1f, 1f, 0.5f)
126 .UseSecondaryColor(0.7f, 0.5f, 0.3f);
127 GameShaders.Armor.BindShader(3535, new ArmorShaderData(pixelShaderRef, "ArmorShiftingPearlsands")).UseImage("Images/Misc/noise").UseColor(1.1f, 0.8f, 0.9f)
128 .UseSecondaryColor(0.35f, 0.25f, 0.44f);
129 GameShaders.Armor.BindShader(3526, new ArmorShaderData(pixelShaderRef, "ArmorSolar")).UseColor(1f, 0f, 0f).UseSecondaryColor(1f, 1f, 0f);
130 GameShaders.Armor.BindShader(3527, new ArmorShaderData(pixelShaderRef, "ArmorNebula")).UseImage("Images/Misc/noise").UseColor(1f, 0f, 1f)
131 .UseSecondaryColor(1f, 1f, 1f)
132 .UseSaturation(1f);
133 GameShaders.Armor.BindShader(3528, new ArmorShaderData(pixelShaderRef, "ArmorVortex")).UseImage("Images/Misc/noise").UseColor(0.1f, 0.5f, 0.35f)
134 .UseSecondaryColor(1f, 1f, 1f)
135 .UseSaturation(1f);
136 GameShaders.Armor.BindShader(3529, new ArmorShaderData(pixelShaderRef, "ArmorStardust")).UseImage("Images/Misc/noise").UseColor(0.4f, 0.6f, 1f)
137 .UseSecondaryColor(1f, 1f, 1f)
138 .UseSaturation(1f);
139 GameShaders.Armor.BindShader(3530, new ArmorShaderData(pixelShaderRef, "ArmorVoid"));
140 FixRecipes();
141 }
142
143 private static void LoadHairDyes()
144 {
145 Ref<Effect> pixelShaderRef = Main.PixelShaderRef;
147 GameShaders.Hair.BindShader(3259, new TwilightHairDyeShaderData(pixelShaderRef, "ArmorTwilight")).UseImage("Images/Misc/noise").UseColor(0.5f, 0.1f, 1f);
148 }
149
150 private static void LoadLegacyHairdyes()
151 {
153 GameShaders.Hair.BindShader(1977, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
154 {
155 newColor.R = (byte)((float)player.statLife / (float)player.statLifeMax2 * 235f + 20f);
156 newColor.B = 20;
157 newColor.G = 20;
158 return newColor;
159 }));
160 GameShaders.Hair.BindShader(1978, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
161 {
162 newColor.R = (byte)((1f - (float)player.statMana / (float)player.statManaMax2) * 200f + 50f);
163 newColor.B = byte.MaxValue;
164 newColor.G = (byte)((1f - (float)player.statMana / (float)player.statManaMax2) * 180f + 75f);
165 return newColor;
166 }));
167 GameShaders.Hair.BindShader(1979, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
168 {
169 float num27 = (float)(Main.worldSurface * 0.45) * 16f;
170 float num28 = (float)(Main.worldSurface + Main.rockLayer) * 8f;
171 float num29 = (float)(Main.rockLayer + (double)Main.maxTilesY) * 8f;
172 float num30 = (float)(Main.maxTilesY - 150) * 16f;
173 Vector2 center = player.Center;
174 if (center.Y < num27)
175 {
176 float num31 = center.Y / num27;
177 float num32 = 1f - num31;
178 newColor.R = (byte)(116f * num32 + 28f * num31);
179 newColor.G = (byte)(160f * num32 + 216f * num31);
180 newColor.B = (byte)(249f * num32 + 94f * num31);
181 }
182 else if (center.Y < num28)
183 {
184 float num33 = num27;
185 float num34 = (center.Y - num33) / (num28 - num33);
186 float num35 = 1f - num34;
187 newColor.R = (byte)(28f * num35 + 151f * num34);
188 newColor.G = (byte)(216f * num35 + 107f * num34);
189 newColor.B = (byte)(94f * num35 + 75f * num34);
190 }
191 else if (center.Y < num29)
192 {
193 float num36 = num28;
194 float num37 = (center.Y - num36) / (num29 - num36);
195 float num38 = 1f - num37;
196 newColor.R = (byte)(151f * num38 + 128f * num37);
197 newColor.G = (byte)(107f * num38 + 128f * num37);
198 newColor.B = (byte)(75f * num38 + 128f * num37);
199 }
200 else if (center.Y < num30)
201 {
202 float num39 = num29;
203 float num40 = (center.Y - num39) / (num30 - num39);
204 float num41 = 1f - num40;
205 newColor.R = (byte)(128f * num41 + 255f * num40);
206 newColor.G = (byte)(128f * num41 + 50f * num40);
207 newColor.B = (byte)(128f * num41 + 15f * num40);
208 }
209 else
210 {
211 newColor.R = byte.MaxValue;
212 newColor.G = 50;
213 newColor.B = 10;
214 }
215 return newColor;
216 }));
217 GameShaders.Hair.BindShader(1980, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
218 {
219 long num15 = 0L;
220 for (int i = 0; i < 54; i++)
221 {
222 if (player.inventory[i].type == 71)
223 {
224 num15 += player.inventory[i].stack;
225 }
226 if (player.inventory[i].type == 72)
227 {
228 num15 += (long)player.inventory[i].stack * 100L;
229 }
230 if (player.inventory[i].type == 73)
231 {
232 num15 += (long)player.inventory[i].stack * 10000L;
233 }
234 if (player.inventory[i].type == 74)
235 {
236 num15 += (long)player.inventory[i].stack * 1000000L;
237 }
238 }
239 if (num15 < 0 || num15 > 999999999)
240 {
241 num15 = 999999999L;
242 }
243 float num16 = Item.buyPrice(0, 5);
244 float num17 = Item.buyPrice(0, 50);
245 float num18 = Item.buyPrice(2);
246 Color color8 = new Color(226, 118, 76);
247 Color color9 = new Color(174, 194, 196);
248 Color color10 = new Color(204, 181, 72);
249 Color color11 = new Color(161, 172, 173);
250 if ((float)num15 < num16)
251 {
252 float num19 = (float)num15 / num16;
253 float num20 = 1f - num19;
254 newColor.R = (byte)((float)(int)color8.R * num20 + (float)(int)color9.R * num19);
255 newColor.G = (byte)((float)(int)color8.G * num20 + (float)(int)color9.G * num19);
256 newColor.B = (byte)((float)(int)color8.B * num20 + (float)(int)color9.B * num19);
257 }
258 else if ((float)num15 < num17)
259 {
260 float num21 = num16;
261 float num22 = ((float)num15 - num21) / (num17 - num21);
262 float num23 = 1f - num22;
263 newColor.R = (byte)((float)(int)color9.R * num23 + (float)(int)color10.R * num22);
264 newColor.G = (byte)((float)(int)color9.G * num23 + (float)(int)color10.G * num22);
265 newColor.B = (byte)((float)(int)color9.B * num23 + (float)(int)color10.B * num22);
266 }
267 else if ((float)num15 < num18)
268 {
269 float num24 = num17;
270 float num25 = ((float)num15 - num24) / (num18 - num24);
271 float num26 = 1f - num25;
272 newColor.R = (byte)((float)(int)color10.R * num26 + (float)(int)color11.R * num25);
273 newColor.G = (byte)((float)(int)color10.G * num26 + (float)(int)color11.G * num25);
274 newColor.B = (byte)((float)(int)color10.B * num26 + (float)(int)color11.B * num25);
275 }
276 else
277 {
278 newColor = color11;
279 }
280 return newColor;
281 }));
282 GameShaders.Hair.BindShader(1981, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
283 {
284 Color color4 = new Color(1, 142, 255);
285 Color color5 = new Color(255, 255, 0);
286 Color color6 = new Color(211, 45, 127);
287 Color color7 = new Color(67, 44, 118);
288 if (Main.dayTime)
289 {
290 if (Main.time < 27000.0)
291 {
292 float num5 = (float)(Main.time / 27000.0);
293 float num6 = 1f - num5;
294 newColor.R = (byte)((float)(int)color4.R * num6 + (float)(int)color5.R * num5);
295 newColor.G = (byte)((float)(int)color4.G * num6 + (float)(int)color5.G * num5);
296 newColor.B = (byte)((float)(int)color4.B * num6 + (float)(int)color5.B * num5);
297 }
298 else
299 {
300 float num7 = 27000f;
301 float num8 = (float)((Main.time - (double)num7) / (54000.0 - (double)num7));
302 float num9 = 1f - num8;
303 newColor.R = (byte)((float)(int)color5.R * num9 + (float)(int)color6.R * num8);
304 newColor.G = (byte)((float)(int)color5.G * num9 + (float)(int)color6.G * num8);
305 newColor.B = (byte)((float)(int)color5.B * num9 + (float)(int)color6.B * num8);
306 }
307 }
308 else if (Main.time < 16200.0)
309 {
310 float num10 = (float)(Main.time / 16200.0);
311 float num11 = 1f - num10;
312 newColor.R = (byte)((float)(int)color6.R * num11 + (float)(int)color7.R * num10);
313 newColor.G = (byte)((float)(int)color6.G * num11 + (float)(int)color7.G * num10);
314 newColor.B = (byte)((float)(int)color6.B * num11 + (float)(int)color7.B * num10);
315 }
316 else
317 {
318 float num12 = 16200f;
319 float num13 = (float)((Main.time - (double)num12) / (32400.0 - (double)num12));
320 float num14 = 1f - num13;
321 newColor.R = (byte)((float)(int)color7.R * num14 + (float)(int)color4.R * num13);
322 newColor.G = (byte)((float)(int)color7.G * num14 + (float)(int)color4.G * num13);
323 newColor.B = (byte)((float)(int)color7.B * num14 + (float)(int)color4.B * num13);
324 }
325 return newColor;
326 }));
327 GameShaders.Hair.BindShader(1982, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
328 {
329 if (player.team >= 0 && player.team < Main.teamColor.Length)
330 {
331 newColor = Main.teamColor[player.team];
332 }
333 return newColor;
334 }));
335 GameShaders.Hair.BindShader(1983, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
336 {
337 Color color2 = default(Color);
338 if (!player.ZoneShimmer)
339 {
340 color2 = ((Main.waterStyle == 2) ? new Color(124, 118, 242) : ((Main.waterStyle == 3) ? new Color(143, 215, 29) : ((Main.waterStyle == 4) ? new Color(78, 193, 227) : ((Main.waterStyle == 5) ? new Color(189, 231, 255) : ((Main.waterStyle == 6) ? new Color(230, 219, 100) : ((Main.waterStyle == 7) ? new Color(151, 107, 75) : ((Main.waterStyle == 8) ? new Color(128, 128, 128) : ((Main.waterStyle == 9) ? new Color(200, 0, 0) : ((Main.waterStyle == 10) ? new Color(208, 80, 80) : ((Main.waterStyle == 12) ? new Color(230, 219, 100) : ((Main.waterStyle != 13) ? new Color(28, 216, 94) : new Color(28, 216, 94))))))))))));
341 }
342 else
343 {
344 TorchID.TorchColor(23, out var R, out var G, out var B);
345 color2 = new Color(R, G, B);
346 }
347 Color color3 = player.hairDyeColor;
348 if (color3.A == 0)
349 {
350 color3 = color2;
351 }
352 if (color3.R > color2.R)
353 {
354 color3.R--;
355 }
356 if (color3.R < color2.R)
357 {
358 color3.R++;
359 }
360 if (color3.G > color2.G)
361 {
362 color3.G--;
363 }
364 if (color3.G < color2.G)
365 {
366 color3.G++;
367 }
368 if (color3.B > color2.B)
369 {
370 color3.B--;
371 }
372 if (color3.B < color2.B)
373 {
374 color3.B++;
375 }
376 newColor = color3;
377 return newColor;
378 }));
379 GameShaders.Hair.BindShader(1984, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
380 {
381 newColor = new Color(244, 22, 175);
382 return newColor;
383 }));
384 GameShaders.Hair.BindShader(1985, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
385 {
386 newColor = new Color(Main.DiscoR, Main.DiscoG, Main.DiscoB);
387 return newColor;
388 }));
389 GameShaders.Hair.BindShader(1986, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
390 {
391 float num = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y);
392 float num2 = 10f;
393 if (num > num2)
394 {
395 num = num2;
396 }
397 float num3 = num / num2;
398 float num4 = 1f - num3;
399 newColor.R = (byte)(75f * num3 + (float)(int)player.hairColor.R * num4);
400 newColor.G = (byte)(255f * num3 + (float)(int)player.hairColor.G * num4);
401 newColor.B = (byte)(200f * num3 + (float)(int)player.hairColor.B * num4);
402 return newColor;
403 }));
404 GameShaders.Hair.BindShader(2863, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
405 {
406 lighting = false;
407 int x = (int)((double)player.position.X + (double)player.width * 0.5) / 16;
408 int y = (int)(((double)player.position.Y + (double)player.height * 0.25) / 16.0);
409 Color color = Lighting.GetColor(x, y);
410 newColor.R = (byte)(color.R + newColor.R >> 1);
411 newColor.G = (byte)(color.G + newColor.G >> 1);
412 newColor.B = (byte)(color.B + newColor.B >> 1);
413 return newColor;
414 }));
415 }
416
417 private static void LoadMisc()
418 {
419 Ref<Effect> pixelShaderRef = Main.PixelShaderRef;
420 GameShaders.Misc["ForceField"] = new MiscShaderData(pixelShaderRef, "ForceField");
421 GameShaders.Misc["WaterProcessor"] = new MiscShaderData(pixelShaderRef, "WaterProcessor");
422 GameShaders.Misc["WaterDistortionObject"] = new MiscShaderData(pixelShaderRef, "WaterDistortionObject");
423 GameShaders.Misc["WaterDebugDraw"] = new MiscShaderData(Main.ScreenShaderRef, "WaterDebugDraw");
424 GameShaders.Misc["HallowBoss"] = new MiscShaderData(pixelShaderRef, "HallowBoss");
425 GameShaders.Misc["HallowBoss"].UseImage1("Images/Extra_" + (short)156);
426 GameShaders.Misc["MaskedFade"] = new MiscShaderData(pixelShaderRef, "MaskedFade");
427 GameShaders.Misc["MaskedFade"].UseImage1("Images/Extra_" + (short)216);
428 GameShaders.Misc["QueenSlime"] = new MiscShaderData(pixelShaderRef, "QueenSlime");
429 GameShaders.Misc["QueenSlime"].UseImage1("Images/Extra_" + (short)180);
430 GameShaders.Misc["QueenSlime"].UseImage2("Images/Extra_" + (short)179);
431 GameShaders.Misc["StardewValleyFade"] = new MiscShaderData(pixelShaderRef, "MaskedFade").UseSamplerState(SamplerState.LinearClamp);
432 GameShaders.Misc["StardewValleyFade"].UseImage1("Images/Extra_" + (short)248);
433 GameShaders.Misc["RainbowTownSlime"] = new MiscShaderData(pixelShaderRef, "RainbowTownSlime");
434 int type = 3530;
435 bool[] array = new bool[GameShaders.Armor.GetShaderIdFromItemId(type) + 1];
436 for (int i = 0; i < array.Length; i++)
437 {
438 array[i] = true;
439 }
440 foreach (int nonColorfulDyeItem in ItemID.Sets.NonColorfulDyeItems)
441 {
442 array[GameShaders.Armor.GetShaderIdFromItemId(nonColorfulDyeItem)] = false;
443 }
444 ItemID.Sets.ColorfulDyeValues = array;
446 }
447
448 private static void LoadMiscVertexShaders()
449 {
450 Ref<Effect> vertexPixelShaderRef = Main.VertexPixelShaderRef;
451 GameShaders.Misc["MagicMissile"] = new MiscShaderData(vertexPixelShaderRef, "MagicMissile").UseProjectionMatrix(doUse: true);
452 GameShaders.Misc["MagicMissile"].UseImage0("Images/Extra_" + (short)192);
453 GameShaders.Misc["MagicMissile"].UseImage1("Images/Extra_" + (short)194);
454 GameShaders.Misc["MagicMissile"].UseImage2("Images/Extra_" + (short)193);
455 GameShaders.Misc["FlameLash"] = new MiscShaderData(vertexPixelShaderRef, "MagicMissile").UseProjectionMatrix(doUse: true);
456 GameShaders.Misc["FlameLash"].UseImage0("Images/Extra_" + (short)191);
457 GameShaders.Misc["FlameLash"].UseImage1("Images/Extra_" + (short)189);
458 GameShaders.Misc["FlameLash"].UseImage2("Images/Extra_" + (short)190);
459 GameShaders.Misc["RainbowRod"] = new MiscShaderData(vertexPixelShaderRef, "MagicMissile").UseProjectionMatrix(doUse: true);
460 GameShaders.Misc["RainbowRod"].UseImage0("Images/Extra_" + (short)195);
461 GameShaders.Misc["RainbowRod"].UseImage1("Images/Extra_" + (short)197);
462 GameShaders.Misc["RainbowRod"].UseImage2("Images/Extra_" + (short)196);
463 GameShaders.Misc["FinalFractal"] = new MiscShaderData(vertexPixelShaderRef, "FinalFractalVertex").UseProjectionMatrix(doUse: true);
464 GameShaders.Misc["FinalFractal"].UseImage0("Images/Extra_" + (short)195);
465 GameShaders.Misc["FinalFractal"].UseImage1("Images/Extra_" + (short)197);
466 GameShaders.Misc["EmpressBlade"] = new MiscShaderData(vertexPixelShaderRef, "FinalFractalVertex").UseProjectionMatrix(doUse: true);
467 GameShaders.Misc["EmpressBlade"].UseImage0("Images/Extra_" + (short)209);
468 GameShaders.Misc["EmpressBlade"].UseImage1("Images/Extra_" + (short)210);
469 GameShaders.Misc["LightDisc"] = new MiscShaderData(vertexPixelShaderRef, "MagicMissile").UseProjectionMatrix(doUse: true);
470 GameShaders.Misc["LightDisc"].UseImage0("Images/Extra_" + (short)195);
471 GameShaders.Misc["LightDisc"].UseImage1("Images/Extra_" + (short)195);
472 GameShaders.Misc["LightDisc"].UseImage2("Images/Extra_" + (short)252);
473 }
474
475 public static void Load()
476 {
478 LoadHairDyes();
479 LoadMisc();
480 }
481
482 private static void FixRecipes()
483 {
484 for (int i = 0; i < Recipe.maxRecipes; i++)
485 {
486 Main.recipe[i].createItem.dye = (byte)GameShaders.Armor.GetShaderIdFromItemId(Main.recipe[i].createItem.type);
487 Main.recipe[i].createItem.hairDye = GameShaders.Hair.GetShaderIdFromItemId(Main.recipe[i].createItem.type);
488 }
489 }
490}
static readonly SamplerState LinearClamp
static double Abs(double value)
Vector2 Center
Definition Entity.cs:43
Vector2 velocity
Definition Entity.cs:16
LegacyHairShaderData UseLegacyMethod(ColorProcessingMethod colorProcessor)
static HairShaderDataSet Hair
Definition GameShaders.cs:9
static Dictionary< string, MiscShaderData > Misc
static ArmorShaderDataSet Armor
Definition GameShaders.cs:7
MiscShaderData UseProjectionMatrix(bool doUse)
MiscShaderData UseSamplerState(SamplerState state)
static List< int > NonColorfulDyeItems
Definition ItemID.cs:152
static void TorchColor(int torchID, out float R, out float G, out float B)
Definition TorchID.cs:164
static void LoadBasicColorDye(int baseDyeItem, float r, float g, float b, float saturation=1f, int oldShader=1)
static void LoadBasicColorDye(int baseDyeItem, int blackDyeItem, int brightDyeItem, int silverDyeItem, float r, float g, float b, float saturation=1f, int oldShader=1)
static int buyPrice(int platinum=0, int gold=0, int silver=0, int copper=0)
Definition Item.cs:47979
int stack
Definition Item.cs:149
static Color GetColor(Point tileCoords)
Definition Lighting.cs:182
static double time
Definition Main.cs:1284
static Recipe[] recipe
Definition Main.cs:1791
static int maxTilesY
Definition Main.cs:1116
static Ref< Effect > VertexPixelShaderRef
Definition Main.cs:423
static double worldSurface
Definition Main.cs:1272
static int DiscoR
Definition Main.cs:1062
static double rockLayer
Definition Main.cs:1274
static bool dayTime
Definition Main.cs:1282
static Ref< Effect > ScreenShaderRef
Definition Main.cs:417
static int DiscoG
Definition Main.cs:1066
static int DiscoB
Definition Main.cs:1064
static Microsoft.Xna.Framework.Color[] teamColor
Definition Main.cs:1276
static Ref< Effect > PixelShaderRef
Definition Main.cs:419
Color hairColor
Definition Player.cs:2133
Color hairDyeColor
Definition Player.cs:2127
Item[] inventory
Definition Player.cs:1257
static int maxRecipes
Definition Recipe.cs:21