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

◆ LoadLegacyHairdyes()

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

Definition at line 151 of file DyeInitializer.cs.

152 {
153 _ = Main.PixelShaderRef;
154 GameShaders.Hair.BindShader(1977, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
155 {
156 //IL_0035: Unknown result type (might be due to invalid IL or missing references)
157 ((Color)(ref newColor)).R = (byte)((float)player.statLife / (float)player.statLifeMax2 * 235f + 20f);
158 ((Color)(ref newColor)).B = 20;
159 ((Color)(ref newColor)).G = 20;
160 return newColor;
161 }));
162 GameShaders.Hair.BindShader(1978, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
163 {
164 //IL_005e: Unknown result type (might be due to invalid IL or missing references)
165 ((Color)(ref newColor)).R = (byte)((1f - (float)player.statMana / (float)player.statManaMax2) * 200f + 50f);
166 ((Color)(ref newColor)).B = byte.MaxValue;
167 ((Color)(ref newColor)).G = (byte)((1f - (float)player.statMana / (float)player.statManaMax2) * 180f + 75f);
168 return newColor;
169 }));
170 GameShaders.Hair.BindShader(1979, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
171 {
172 //IL_0052: Unknown result type (might be due to invalid IL or missing references)
173 //IL_0057: Unknown result type (might be due to invalid IL or missing references)
174 //IL_0059: Unknown result type (might be due to invalid IL or missing references)
175 //IL_00c8: Unknown result type (might be due to invalid IL or missing references)
176 //IL_0063: Unknown result type (might be due to invalid IL or missing references)
177 //IL_0140: Unknown result type (might be due to invalid IL or missing references)
178 //IL_00d5: Unknown result type (might be due to invalid IL or missing references)
179 //IL_024b: Unknown result type (might be due to invalid IL or missing references)
180 //IL_01b8: Unknown result type (might be due to invalid IL or missing references)
181 //IL_014d: Unknown result type (might be due to invalid IL or missing references)
182 //IL_01c5: Unknown result type (might be due to invalid IL or missing references)
183 float num27 = (float)(Main.worldSurface * 0.45) * 16f;
184 float num28 = (float)(Main.worldSurface + Main.rockLayer) * 8f;
185 float num29 = (float)(Main.rockLayer + (double)Main.maxTilesY) * 8f;
186 float num30 = (float)(Main.maxTilesY - 150) * 16f;
187 Vector2 center = player.Center;
188 if (center.Y < num27)
189 {
190 float num31 = center.Y / num27;
191 float num32 = 1f - num31;
192 ((Color)(ref newColor)).R = (byte)(116f * num32 + 28f * num31);
193 ((Color)(ref newColor)).G = (byte)(160f * num32 + 216f * num31);
194 ((Color)(ref newColor)).B = (byte)(249f * num32 + 94f * num31);
195 }
196 else if (center.Y < num28)
197 {
198 float num33 = num27;
199 float num34 = (center.Y - num33) / (num28 - num33);
200 float num35 = 1f - num34;
201 ((Color)(ref newColor)).R = (byte)(28f * num35 + 151f * num34);
202 ((Color)(ref newColor)).G = (byte)(216f * num35 + 107f * num34);
203 ((Color)(ref newColor)).B = (byte)(94f * num35 + 75f * num34);
204 }
205 else if (center.Y < num29)
206 {
207 float num36 = num28;
208 float num37 = (center.Y - num36) / (num29 - num36);
209 float num38 = 1f - num37;
210 ((Color)(ref newColor)).R = (byte)(151f * num38 + 128f * num37);
211 ((Color)(ref newColor)).G = (byte)(107f * num38 + 128f * num37);
212 ((Color)(ref newColor)).B = (byte)(75f * num38 + 128f * num37);
213 }
214 else if (center.Y < num30)
215 {
216 float num39 = num29;
217 float num40 = (center.Y - num39) / (num30 - num39);
218 float num41 = 1f - num40;
219 ((Color)(ref newColor)).R = (byte)(128f * num41 + 255f * num40);
220 ((Color)(ref newColor)).G = (byte)(128f * num41 + 50f * num40);
221 ((Color)(ref newColor)).B = (byte)(128f * num41 + 15f * num40);
222 }
223 else
224 {
225 ((Color)(ref newColor)).R = byte.MaxValue;
226 ((Color)(ref newColor)).G = 50;
227 ((Color)(ref newColor)).B = 10;
228 }
229 return newColor;
230 }));
231 GameShaders.Hair.BindShader(1980, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
232 {
233 //IL_02ba: Unknown result type (might be due to invalid IL or missing references)
234 //IL_02b6: Unknown result type (might be due to invalid IL or missing references)
235 //IL_02b8: Unknown result type (might be due to invalid IL or missing references)
236 long num15 = 0L;
237 for (int i = 0; i < 54; i++)
238 {
239 if (player.inventory[i].type == 71)
240 {
241 num15 += player.inventory[i].stack;
242 }
243 if (player.inventory[i].type == 72)
244 {
245 num15 += (long)player.inventory[i].stack * 100L;
246 }
247 if (player.inventory[i].type == 73)
248 {
249 num15 += (long)player.inventory[i].stack * 10000L;
250 }
251 if (player.inventory[i].type == 74)
252 {
253 num15 += (long)player.inventory[i].stack * 1000000L;
254 }
255 }
256 if (num15 < 0 || num15 > 999999999)
257 {
258 num15 = 999999999L;
259 }
260 float num16 = Item.buyPrice(0, 5);
261 float num17 = Item.buyPrice(0, 50);
262 float num18 = Item.buyPrice(2);
263 Color val7 = default(Color);
264 ((Color)(ref val7))._002Ector(226, 118, 76);
265 Color val8 = default(Color);
266 ((Color)(ref val8))._002Ector(174, 194, 196);
267 Color val9 = default(Color);
268 ((Color)(ref val9))._002Ector(204, 181, 72);
269 Color val10 = default(Color);
270 ((Color)(ref val10))._002Ector(161, 172, 173);
271 if ((float)num15 < num16)
272 {
273 float num19 = (float)num15 / num16;
274 float num20 = 1f - num19;
275 ((Color)(ref newColor)).R = (byte)((float)(int)((Color)(ref val7)).R * num20 + (float)(int)((Color)(ref val8)).R * num19);
276 ((Color)(ref newColor)).G = (byte)((float)(int)((Color)(ref val7)).G * num20 + (float)(int)((Color)(ref val8)).G * num19);
277 ((Color)(ref newColor)).B = (byte)((float)(int)((Color)(ref val7)).B * num20 + (float)(int)((Color)(ref val8)).B * num19);
278 }
279 else if ((float)num15 < num17)
280 {
281 float num21 = num16;
282 float num22 = ((float)num15 - num21) / (num17 - num21);
283 float num23 = 1f - num22;
284 ((Color)(ref newColor)).R = (byte)((float)(int)((Color)(ref val8)).R * num23 + (float)(int)((Color)(ref val9)).R * num22);
285 ((Color)(ref newColor)).G = (byte)((float)(int)((Color)(ref val8)).G * num23 + (float)(int)((Color)(ref val9)).G * num22);
286 ((Color)(ref newColor)).B = (byte)((float)(int)((Color)(ref val8)).B * num23 + (float)(int)((Color)(ref val9)).B * num22);
287 }
288 else if ((float)num15 < num18)
289 {
290 float num24 = num17;
291 float num25 = ((float)num15 - num24) / (num18 - num24);
292 float num26 = 1f - num25;
293 ((Color)(ref newColor)).R = (byte)((float)(int)((Color)(ref val9)).R * num26 + (float)(int)((Color)(ref val10)).R * num25);
294 ((Color)(ref newColor)).G = (byte)((float)(int)((Color)(ref val9)).G * num26 + (float)(int)((Color)(ref val10)).G * num25);
295 ((Color)(ref newColor)).B = (byte)((float)(int)((Color)(ref val9)).B * num26 + (float)(int)((Color)(ref val10)).B * num25);
296 }
297 else
298 {
299 newColor = val10;
300 }
301 return newColor;
302 }));
303 GameShaders.Hair.BindShader(1981, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
304 {
305 //IL_027c: Unknown result type (might be due to invalid IL or missing references)
306 Color val3 = default(Color);
307 ((Color)(ref val3))._002Ector(1, 142, 255);
308 Color val4 = default(Color);
309 ((Color)(ref val4))._002Ector(255, 255, 0);
310 Color val5 = default(Color);
311 ((Color)(ref val5))._002Ector(211, 45, 127);
312 Color val6 = default(Color);
313 ((Color)(ref val6))._002Ector(67, 44, 118);
314 if (Main.dayTime)
315 {
316 if (Main.time < 27000.0)
317 {
318 float num5 = (float)(Main.time / 27000.0);
319 float num6 = 1f - num5;
320 ((Color)(ref newColor)).R = (byte)((float)(int)((Color)(ref val3)).R * num6 + (float)(int)((Color)(ref val4)).R * num5);
321 ((Color)(ref newColor)).G = (byte)((float)(int)((Color)(ref val3)).G * num6 + (float)(int)((Color)(ref val4)).G * num5);
322 ((Color)(ref newColor)).B = (byte)((float)(int)((Color)(ref val3)).B * num6 + (float)(int)((Color)(ref val4)).B * num5);
323 }
324 else
325 {
326 float num7 = 27000f;
327 float num8 = (float)((Main.time - (double)num7) / (54000.0 - (double)num7));
328 float num9 = 1f - num8;
329 ((Color)(ref newColor)).R = (byte)((float)(int)((Color)(ref val4)).R * num9 + (float)(int)((Color)(ref val5)).R * num8);
330 ((Color)(ref newColor)).G = (byte)((float)(int)((Color)(ref val4)).G * num9 + (float)(int)((Color)(ref val5)).G * num8);
331 ((Color)(ref newColor)).B = (byte)((float)(int)((Color)(ref val4)).B * num9 + (float)(int)((Color)(ref val5)).B * num8);
332 }
333 }
334 else if (Main.time < 16200.0)
335 {
336 float num10 = (float)(Main.time / 16200.0);
337 float num11 = 1f - num10;
338 ((Color)(ref newColor)).R = (byte)((float)(int)((Color)(ref val5)).R * num11 + (float)(int)((Color)(ref val6)).R * num10);
339 ((Color)(ref newColor)).G = (byte)((float)(int)((Color)(ref val5)).G * num11 + (float)(int)((Color)(ref val6)).G * num10);
340 ((Color)(ref newColor)).B = (byte)((float)(int)((Color)(ref val5)).B * num11 + (float)(int)((Color)(ref val6)).B * num10);
341 }
342 else
343 {
344 float num12 = 16200f;
345 float num13 = (float)((Main.time - (double)num12) / (32400.0 - (double)num12));
346 float num14 = 1f - num13;
347 ((Color)(ref newColor)).R = (byte)((float)(int)((Color)(ref val6)).R * num14 + (float)(int)((Color)(ref val3)).R * num13);
348 ((Color)(ref newColor)).G = (byte)((float)(int)((Color)(ref val6)).G * num14 + (float)(int)((Color)(ref val3)).G * num13);
349 ((Color)(ref newColor)).B = (byte)((float)(int)((Color)(ref val6)).B * num14 + (float)(int)((Color)(ref val3)).B * num13);
350 }
351 return newColor;
352 }));
353 GameShaders.Hair.BindShader(1982, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
354 {
355 //IL_002a: Unknown result type (might be due to invalid IL or missing references)
356 //IL_0023: Unknown result type (might be due to invalid IL or missing references)
357 //IL_0028: Unknown result type (might be due to invalid IL or missing references)
358 if (player.team >= 0 && player.team < Main.teamColor.Length)
359 {
360 newColor = Main.teamColor[player.team];
361 }
362 return newColor;
363 }));
364 GameShaders.Hair.BindShader(1983, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
365 {
366 //IL_0002: Unknown result type (might be due to invalid IL or missing references)
367 //IL_01a1: Unknown result type (might be due to invalid IL or missing references)
368 //IL_01a6: Unknown result type (might be due to invalid IL or missing references)
369 //IL_0162: Unknown result type (might be due to invalid IL or missing references)
370 //IL_01b0: Unknown result type (might be due to invalid IL or missing references)
371 //IL_01b1: Unknown result type (might be due to invalid IL or missing references)
372 //IL_0167: Unknown result type (might be due to invalid IL or missing references)
373 //IL_0152: Unknown result type (might be due to invalid IL or missing references)
374 //IL_0180: Unknown result type (might be due to invalid IL or missing references)
375 //IL_0185: Unknown result type (might be due to invalid IL or missing references)
376 //IL_013f: Unknown result type (might be due to invalid IL or missing references)
377 //IL_012c: Unknown result type (might be due to invalid IL or missing references)
378 //IL_0116: Unknown result type (might be due to invalid IL or missing references)
379 //IL_0103: Unknown result type (might be due to invalid IL or missing references)
380 //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
381 //IL_028a: Unknown result type (might be due to invalid IL or missing references)
382 //IL_028b: Unknown result type (might be due to invalid IL or missing references)
383 //IL_028d: Unknown result type (might be due to invalid IL or missing references)
384 //IL_00da: Unknown result type (might be due to invalid IL or missing references)
385 //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
386 //IL_00b6: Unknown result type (might be due to invalid IL or missing references)
387 //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
388 //IL_008d: Unknown result type (might be due to invalid IL or missing references)
389 Color val = default(Color);
390 if (!player.ZoneShimmer)
391 {
392 val = ((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))))))))))));
393 if (Main.waterStyle >= 15)
394 {
395 val = LoaderManager.Get<WaterStylesLoader>().Get(Main.waterStyle).BiomeHairColor();
396 }
397 }
398 else
399 {
400 TorchID.TorchColor(23, out var R, out var G, out var B);
401 ((Color)(ref val))._002Ector(R, G, B);
402 }
403 Color val2 = player.hairDyeColor;
404 if (((Color)(ref val2)).A == 0)
405 {
406 val2 = val;
407 }
408 if (((Color)(ref val2)).R > ((Color)(ref val)).R)
409 {
410 byte r = ((Color)(ref val2)).R;
411 ((Color)(ref val2)).R = (byte)(r - 1);
412 }
413 if (((Color)(ref val2)).R < ((Color)(ref val)).R)
414 {
415 byte r = ((Color)(ref val2)).R;
416 ((Color)(ref val2)).R = (byte)(r + 1);
417 }
418 if (((Color)(ref val2)).G > ((Color)(ref val)).G)
419 {
420 byte r = ((Color)(ref val2)).G;
421 ((Color)(ref val2)).G = (byte)(r - 1);
422 }
423 if (((Color)(ref val2)).G < ((Color)(ref val)).G)
424 {
425 byte r = ((Color)(ref val2)).G;
426 ((Color)(ref val2)).G = (byte)(r + 1);
427 }
428 if (((Color)(ref val2)).B > ((Color)(ref val)).B)
429 {
430 byte r = ((Color)(ref val2)).B;
431 ((Color)(ref val2)).B = (byte)(r - 1);
432 }
433 if (((Color)(ref val2)).B < ((Color)(ref val)).B)
434 {
435 byte r = ((Color)(ref val2)).B;
436 ((Color)(ref val2)).B = (byte)(r + 1);
437 }
438 newColor = val2;
439 return newColor;
440 }));
441 GameShaders.Hair.BindShader(1984, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
442 {
443 //IL_0013: Unknown result type (might be due to invalid IL or missing references)
444 ((Color)(ref newColor))._002Ector(244, 22, 175);
445 return newColor;
446 }));
447 GameShaders.Hair.BindShader(1985, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
448 {
449 //IL_0016: Unknown result type (might be due to invalid IL or missing references)
450 ((Color)(ref newColor))._002Ector(Main.DiscoR, Main.DiscoG, Main.DiscoB);
451 return newColor;
452 }));
453 GameShaders.Hair.BindShader(1986, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
454 {
455 //IL_0094: Unknown result type (might be due to invalid IL or missing references)
456 float num = Math.Abs(player.velocity.X) + Math.Abs(player.velocity.Y);
457 float num2 = 10f;
458 if (num > num2)
459 {
460 num = num2;
461 }
462 float num3 = num / num2;
463 float num4 = 1f - num3;
464 ((Color)(ref newColor)).R = (byte)(75f * num3 + (float)(int)((Color)(ref player.hairColor)).R * num4);
465 ((Color)(ref newColor)).G = (byte)(255f * num3 + (float)(int)((Color)(ref player.hairColor)).G * num4);
466 ((Color)(ref newColor)).B = (byte)(200f * num3 + (float)(int)((Color)(ref player.hairColor)).B * num4);
467 return newColor;
468 }));
469 GameShaders.Hair.BindShader(2863, new LegacyHairShaderData().UseLegacyMethod(delegate(Player player, Color newColor, ref bool lighting)
470 {
471 //IL_0050: Unknown result type (might be due to invalid IL or missing references)
472 //IL_0055: Unknown result type (might be due to invalid IL or missing references)
473 //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
474 lighting = false;
475 int x = (int)((double)player.position.X + (double)player.width * 0.5) / 16;
476 int y = (int)(((double)player.position.Y + (double)player.height * 0.25) / 16.0);
477 Color color = Lighting.GetColor(x, y);
478 ((Color)(ref newColor)).R = (byte)(((Color)(ref color)).R + ((Color)(ref newColor)).R >> 1);
479 ((Color)(ref newColor)).G = (byte)(((Color)(ref color)).G + ((Color)(ref newColor)).G >> 1);
480 ((Color)(ref newColor)).B = (byte)(((Color)(ref color)).B + ((Color)(ref newColor)).B >> 1);
481 return newColor;
482 }));
483 }
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 Terraria.Item.buyPrice(), Terraria.Entity.Center, Terraria.Main.dayTime, Terraria.Main.DiscoB, Terraria.Main.DiscoG, Terraria.Main.DiscoR, Terraria.Lighting.GetColor(), Terraria.Graphics.Shaders.GameShaders.Hair, Terraria.Player.hairColor, Terraria.Player.hairDyeColor, Terraria.Entity.height, Terraria.Player.inventory, Terraria.Main.maxTilesY, Terraria.Main.PixelShaderRef, Terraria.Main.rockLayer, Terraria.Item.stack, 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.Main.waterStyle, Terraria.Entity.width, Terraria.Main.worldSurface, and Terraria.Player.ZoneShimmer.

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function: