Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ LoadLegacyHairdyes()

static void Terraria.Initializers.DyeInitializer.LoadLegacyHairdyes ( )
inlinestaticprivate

Definition at line 150 of file DyeInitializer.cs.

151 {
152 _ = Main.PixelShaderRef;
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 }
static double Abs(double value)
LegacyHairShaderData UseLegacyMethod(ColorProcessingMethod colorProcessor)
static HairShaderDataSet Hair
Definition GameShaders.cs:9
static void TorchColor(int torchID, out float R, out float G, out float B)
Definition TorchID.cs:164

References Microsoft.Xna.Framework.Color.A, System.Math.Abs(), Microsoft.Xna.Framework.Color.B, System.B, Terraria.Item.buyPrice(), Terraria.Entity.Center, Microsoft.Xna.Framework.Graphics.Color, Terraria.Main.dayTime, Terraria.Main.DiscoB, Terraria.Main.DiscoG, Terraria.Main.DiscoR, Microsoft.Xna.Framework.Color.G, System.G, Terraria.Lighting.GetColor(), Terraria.Graphics.Shaders.GameShaders.Hair, Terraria.Player.hairColor, Terraria.Player.hairDyeColor, Terraria.Entity.height, Terraria.Player.inventory, System.L, Terraria.Main.maxTilesY, Terraria.Main.PixelShaderRef, Microsoft.Xna.Framework.Color.R, System.R, Terraria.Main.rockLayer, Terraria.Item.stack, Terraria.Player.statLife, Terraria.Player.statLifeMax2, Terraria.Player.statMana, Terraria.Player.statManaMax2, Terraria.Player.team, Terraria.Main.teamColor, Terraria.Main.time, Terraria.ID.TorchID.TorchColor(), Terraria.Item.type, Terraria.GameContent.Dyes.LegacyHairShaderData.UseLegacyMethod(), Terraria.Entity.velocity, Terraria.Entity.width, Terraria.Main.worldSurface, Microsoft.Xna.Framework.Vector2.X, Microsoft.Xna.Framework.Vector2.Y, and Terraria.Player.ZoneShimmer.

Referenced by Terraria.Initializers.DyeInitializer.LoadHairDyes().