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

◆ SetBackColor()

static void Terraria.Main.SetBackColor ( InfoToSetBackColor info,
out Microsoft::Xna::Framework::Color sunColor,
out Microsoft::Xna::Framework::Color moonColor )
inlinestaticprivate

Definition at line 60291 of file Main.cs.

60292 {
60293 double num = time;
60297 float num2 = 0f;
60298 bool isInGameMenuOrIsServer = info.isInGameMenuOrIsServer;
60299 if (dayTime)
60300 {
60301 if (num < 13500.0)
60302 {
60303 num2 = (float)(num / 13500.0);
60304 sunColor.R = (byte)(num2 * 200f + 55f);
60305 sunColor.G = (byte)(num2 * 180f + 75f);
60306 sunColor.B = (byte)(num2 * 250f + 5f);
60307 bgColorToSet.R = (byte)(num2 * 230f + 25f);
60308 bgColorToSet.G = (byte)(num2 * 220f + 35f);
60309 bgColorToSet.B = (byte)(num2 * 220f + 35f);
60310 }
60311 if (num > 45900.0)
60312 {
60313 num2 = (float)(1.0 - (num / 54000.0 - 0.85) * 6.666666666666667);
60314 sunColor.R = (byte)(num2 * 120f + 55f);
60315 sunColor.G = (byte)(num2 * 100f + 25f);
60316 sunColor.B = (byte)(num2 * 120f + 55f);
60317 bgColorToSet.R = (byte)(num2 * 200f + 35f);
60318 bgColorToSet.G = (byte)(num2 * 85f + 35f);
60319 bgColorToSet.B = (byte)(num2 * 135f + 35f);
60320 }
60321 else if (num > 37800.0)
60322 {
60323 num2 = (float)(1.0 - (num / 54000.0 - 0.7) * 6.666666666666667);
60324 sunColor.R = (byte)(num2 * 80f + 175f);
60325 sunColor.G = (byte)(num2 * 130f + 125f);
60326 sunColor.B = (byte)(num2 * 100f + 155f);
60327 bgColorToSet.R = (byte)(num2 * 20f + 235f);
60328 bgColorToSet.G = (byte)(num2 * 135f + 120f);
60329 bgColorToSet.B = (byte)(num2 * 85f + 170f);
60330 }
60331 }
60332 if (!dayTime)
60333 {
60334 if (info.BloodMoonActive)
60335 {
60336 if (num < 16200.0)
60337 {
60338 num2 = (float)(1.0 - num / 16200.0);
60339 moonColor.R = (byte)(num2 * 10f + 205f);
60340 moonColor.G = (byte)(num2 * 170f + 55f);
60341 moonColor.B = (byte)(num2 * 200f + 55f);
60342 bgColorToSet.R = (byte)(40f - num2 * 40f + 35f);
60343 bgColorToSet.G = (byte)(num2 * 20f + 15f);
60344 bgColorToSet.B = (byte)(num2 * 20f + 15f);
60345 }
60346 else if (num >= 16200.0)
60347 {
60348 num2 = (float)((num / 32400.0 - 0.5) * 2.0);
60349 moonColor.R = (byte)(num2 * 50f + 205f);
60350 moonColor.G = (byte)(num2 * 100f + 155f);
60351 moonColor.B = (byte)(num2 * 100f + 155f);
60352 moonColor.R = (byte)(num2 * 10f + 205f);
60353 moonColor.G = (byte)(num2 * 170f + 55f);
60354 moonColor.B = (byte)(num2 * 200f + 55f);
60355 bgColorToSet.R = (byte)(40f - num2 * 40f + 35f);
60356 bgColorToSet.G = (byte)(num2 * 20f + 15f);
60357 bgColorToSet.B = (byte)(num2 * 20f + 15f);
60358 }
60359 }
60360 else if (num < 16200.0)
60361 {
60362 num2 = (float)(1.0 - num / 16200.0);
60363 moonColor.R = (byte)(num2 * 10f + 205f);
60364 moonColor.G = (byte)(num2 * 70f + 155f);
60365 moonColor.B = (byte)(num2 * 100f + 155f);
60366 bgColorToSet.R = (byte)(num2 * 30f + 5f);
60367 bgColorToSet.G = (byte)(num2 * 30f + 5f);
60368 bgColorToSet.B = (byte)(num2 * 30f + 5f);
60369 }
60370 else if (num >= 16200.0)
60371 {
60372 num2 = (float)((num / 32400.0 - 0.5) * 2.0);
60373 moonColor.R = (byte)(num2 * 50f + 205f);
60374 moonColor.G = (byte)(num2 * 100f + 155f);
60375 moonColor.B = (byte)(num2 * 100f + 155f);
60376 bgColorToSet.R = (byte)(num2 * 20f + 5f);
60377 bgColorToSet.G = (byte)(num2 * 30f + 5f);
60378 bgColorToSet.B = (byte)(num2 * 30f + 5f);
60379 }
60380 if (dontStarveWorld)
60381 {
60383 }
60384 }
60385 if (cloudAlpha > 0f && !remixWorld)
60386 {
60387 float num3 = 1f - cloudAlpha * 0.9f * atmo;
60388 bgColorToSet.R = (byte)((float)(int)bgColorToSet.R * num3);
60389 bgColorToSet.G = (byte)((float)(int)bgColorToSet.G * num3);
60390 bgColorToSet.B = (byte)((float)(int)bgColorToSet.B * num3);
60391 }
60392 if (info.GraveyardInfluence > 0f && !remixWorld)
60393 {
60394 float num4 = 1f - info.GraveyardInfluence * 0.6f;
60395 bgColorToSet.R = (byte)((float)(int)bgColorToSet.R * num4);
60396 bgColorToSet.G = (byte)((float)(int)bgColorToSet.G * num4);
60397 bgColorToSet.B = (byte)((float)(int)bgColorToSet.B * num4);
60398 }
60399 if (isInGameMenuOrIsServer && !dayTime)
60400 {
60401 bgColorToSet.R = 35;
60402 bgColorToSet.G = 35;
60403 bgColorToSet.B = 35;
60404 }
60405 if (info.CorruptionBiomeInfluence > 0f)
60406 {
60407 float num5 = info.CorruptionBiomeInfluence;
60408 if (num5 > 1f)
60409 {
60410 num5 = 1f;
60411 }
60412 int r = bgColorToSet.R;
60413 int g = bgColorToSet.G;
60414 int b = bgColorToSet.B;
60415 r -= (int)(90f * num5 * ((float)(int)bgColorToSet.R / 255f));
60416 g -= (int)(140f * num5 * ((float)(int)bgColorToSet.G / 255f));
60417 b -= (int)(70f * num5 * ((float)(int)bgColorToSet.B / 255f));
60418 if (r < 15)
60419 {
60420 r = 15;
60421 }
60422 if (g < 15)
60423 {
60424 g = 15;
60425 }
60426 if (b < 15)
60427 {
60428 b = 15;
60429 }
60431 bgColorToSet.R = (byte)r;
60432 bgColorToSet.G = (byte)g;
60433 bgColorToSet.B = (byte)b;
60434 r = sunColor.R;
60435 g = sunColor.G;
60436 b = sunColor.B;
60437 r -= (int)(100f * num5 * ((float)(int)sunColor.R / 255f));
60438 g -= (int)(100f * num5 * ((float)(int)sunColor.G / 255f));
60439 b -= (int)(0f * num5 * ((float)(int)sunColor.B / 255f));
60440 if (r < 15)
60441 {
60442 r = 15;
60443 }
60444 if (g < 15)
60445 {
60446 g = 15;
60447 }
60448 if (b < 15)
60449 {
60450 b = 15;
60451 }
60452 sunColor.R = (byte)r;
60453 sunColor.G = (byte)g;
60454 sunColor.B = (byte)b;
60455 }
60456 if (info.CrimsonBiomeInfluence > 0f)
60457 {
60458 float num6 = info.CrimsonBiomeInfluence;
60459 if (num6 > 1f)
60460 {
60461 num6 = 1f;
60462 }
60463 int r2 = bgColorToSet.R;
60464 int g2 = bgColorToSet.G;
60465 int b2 = bgColorToSet.B;
60466 r2 -= (int)(40f * num6 * ((float)(int)bgColorToSet.G / 255f));
60467 g2 -= (int)(110f * num6 * ((float)(int)bgColorToSet.G / 255f));
60468 b2 -= (int)(140f * num6 * ((float)(int)bgColorToSet.B / 255f));
60469 if (r2 < 15)
60470 {
60471 r2 = 15;
60472 }
60473 if (g2 < 15)
60474 {
60475 g2 = 15;
60476 }
60477 if (b2 < 15)
60478 {
60479 b2 = 15;
60480 }
60482 bgColorToSet.R = (byte)r2;
60483 bgColorToSet.G = (byte)g2;
60484 bgColorToSet.B = (byte)b2;
60485 r2 = sunColor.R;
60486 g2 = sunColor.G;
60487 b2 = sunColor.B;
60488 g2 -= (int)(90f * num6 * ((float)(int)sunColor.G / 255f));
60489 b2 -= (int)(110f * num6 * ((float)(int)sunColor.B / 255f));
60490 if (r2 < 15)
60491 {
60492 r2 = 15;
60493 }
60494 if (g2 < 15)
60495 {
60496 g2 = 15;
60497 }
60498 if (b2 < 15)
60499 {
60500 b2 = 15;
60501 }
60502 sunColor.R = (byte)r2;
60503 sunColor.G = (byte)g2;
60504 sunColor.B = (byte)b2;
60505 }
60506 if (info.JungleBiomeInfluence > 0f)
60507 {
60508 float num7 = info.JungleBiomeInfluence;
60509 if (num7 > 1f)
60510 {
60511 num7 = 1f;
60512 }
60513 int r3 = bgColorToSet.R;
60514 int G = bgColorToSet.G;
60515 int b3 = bgColorToSet.B;
60516 r3 -= (int)(40f * num7 * ((float)(int)bgColorToSet.R / 255f));
60517 b3 -= (int)(70f * num7 * ((float)(int)bgColorToSet.B / 255f));
60518 if (G > 255)
60519 {
60520 G = 255;
60521 }
60522 if (G < 15)
60523 {
60524 G = 15;
60525 }
60526 if (r3 > 255)
60527 {
60528 r3 = 255;
60529 }
60530 if (r3 < 15)
60531 {
60532 r3 = 15;
60533 }
60534 if (b3 < 15)
60535 {
60536 b3 = 15;
60537 }
60539 bgColorToSet.R = (byte)r3;
60540 bgColorToSet.G = (byte)G;
60541 bgColorToSet.B = (byte)b3;
60542 r3 = sunColor.R;
60543 G = sunColor.G;
60544 b3 = sunColor.B;
60545 r3 -= (int)(30f * num7 * ((float)(int)sunColor.R / 255f));
60546 b3 -= (int)(10f * num7 * ((float)(int)sunColor.B / 255f));
60547 if (r3 < 15)
60548 {
60549 r3 = 15;
60550 }
60551 if (G < 15)
60552 {
60553 G = 15;
60554 }
60555 if (b3 < 15)
60556 {
60557 b3 = 15;
60558 }
60559 sunColor.R = (byte)r3;
60560 sunColor.G = (byte)G;
60561 sunColor.B = (byte)b3;
60562 }
60563 if (info.MushroomBiomeInfluence > 0f)
60564 {
60565 float mushroomBiomeInfluence = info.MushroomBiomeInfluence;
60566 int r4 = bgColorToSet.R;
60567 int g3 = bgColorToSet.G;
60568 int b4 = bgColorToSet.B;
60569 g3 -= (int)(250f * mushroomBiomeInfluence * ((float)(int)bgColorToSet.G / 255f));
60570 r4 -= (int)(250f * mushroomBiomeInfluence * ((float)(int)bgColorToSet.R / 255f));
60571 b4 -= (int)(250f * mushroomBiomeInfluence * ((float)(int)bgColorToSet.B / 255f));
60572 if (g3 < 15)
60573 {
60574 g3 = 15;
60575 }
60576 if (r4 < 15)
60577 {
60578 r4 = 15;
60579 }
60580 if (b4 < 15)
60581 {
60582 b4 = 15;
60583 }
60585 bgColorToSet.R = (byte)r4;
60586 bgColorToSet.G = (byte)g3;
60587 bgColorToSet.B = (byte)b4;
60588 r4 = sunColor.R;
60589 g3 = sunColor.G;
60590 b4 = sunColor.B;
60591 g3 -= (int)(10f * mushroomBiomeInfluence * ((float)(int)sunColor.G / 255f));
60592 r4 -= (int)(30f * mushroomBiomeInfluence * ((float)(int)sunColor.R / 255f));
60593 b4 -= (int)(10f * mushroomBiomeInfluence * ((float)(int)sunColor.B / 255f));
60594 if (r4 < 15)
60595 {
60596 r4 = 15;
60597 }
60598 if (g3 < 15)
60599 {
60600 g3 = 15;
60601 }
60602 if (b4 < 15)
60603 {
60604 b4 = 15;
60605 }
60606 sunColor.R = (byte)r4;
60607 sunColor.G = (byte)g3;
60608 sunColor.B = (byte)b4;
60609 r4 = moonColor.R;
60610 g3 = moonColor.G;
60611 b4 = moonColor.B;
60612 g3 -= (int)(140f * mushroomBiomeInfluence * ((float)(int)moonColor.R / 255f));
60613 r4 -= (int)(170f * mushroomBiomeInfluence * ((float)(int)moonColor.G / 255f));
60614 b4 -= (int)(190f * mushroomBiomeInfluence * ((float)(int)moonColor.B / 255f));
60615 if (r4 < 15)
60616 {
60617 r4 = 15;
60618 }
60619 if (g3 < 15)
60620 {
60621 g3 = 15;
60622 }
60623 if (b4 < 15)
60624 {
60625 b4 = 15;
60626 }
60627 moonColor.R = (byte)r4;
60628 moonColor.G = (byte)g3;
60629 moonColor.B = (byte)b4;
60630 }
60631 byte minimalLight = 15;
60632 switch (GetMoonPhase())
60633 {
60634 case MoonPhase.Empty:
60635 minimalLight = 11;
60636 break;
60637 case MoonPhase.QuarterAtLeft:
60638 case MoonPhase.QuarterAtRight:
60639 minimalLight = 13;
60640 break;
60641 case MoonPhase.HalfAtLeft:
60642 case MoonPhase.HalfAtRight:
60643 minimalLight = 15;
60644 break;
60645 case MoonPhase.ThreeQuartersAtLeft:
60646 case MoonPhase.ThreeQuartersAtRight:
60647 minimalLight = 17;
60648 break;
60649 case MoonPhase.Full:
60650 minimalLight = 19;
60651 break;
60652 }
60653 if (dontStarveWorld)
60654 {
60656 }
60657 if (bgColorToSet.R < minimalLight)
60658 {
60659 bgColorToSet.R = minimalLight;
60660 }
60661 if (bgColorToSet.G < minimalLight)
60662 {
60663 bgColorToSet.G = minimalLight;
60664 }
60665 if (bgColorToSet.B < minimalLight)
60666 {
60667 bgColorToSet.B = minimalLight;
60668 }
60669 if (info.BloodMoonActive)
60670 {
60671 if (bgColorToSet.R < 25)
60672 {
60673 bgColorToSet.R = 25;
60674 }
60675 if (bgColorToSet.G < 25)
60676 {
60677 bgColorToSet.G = 25;
60678 }
60679 if (bgColorToSet.B < 25)
60680 {
60681 bgColorToSet.B = 25;
60682 }
60683 }
60684 if (eclipse && dayTime)
60685 {
60686 float num8 = 1242f;
60687 eclipseLight = (float)(num / (double)num8);
60688 if (eclipseLight > 1f)
60689 {
60690 eclipseLight = 1f;
60691 }
60692 }
60693 else if (eclipseLight > 0f)
60694 {
60695 eclipseLight -= 0.01f;
60696 if (eclipseLight < 0f)
60697 {
60698 eclipseLight = 0f;
60699 }
60700 }
60701 if (eclipseLight > 0f)
60702 {
60703 float num9 = 1f - 0.925f * eclipseLight;
60704 float num10 = 1f - 0.96f * eclipseLight;
60705 float num11 = 1f - 1f * eclipseLight;
60706 int num12 = (int)((float)(int)bgColorToSet.R * num9);
60707 int num13 = (int)((float)(int)bgColorToSet.G * num10);
60708 int num14 = (int)((float)(int)bgColorToSet.B * num11);
60709 bgColorToSet.R = (byte)num12;
60710 bgColorToSet.G = (byte)num13;
60711 bgColorToSet.B = (byte)num14;
60712 sunColor.R = byte.MaxValue;
60713 sunColor.G = 127;
60714 sunColor.B = 67;
60715 if (bgColorToSet.R < 20)
60716 {
60717 bgColorToSet.R = 20;
60718 }
60719 if (bgColorToSet.G < 10)
60720 {
60721 bgColorToSet.G = 10;
60722 }
60723 if (!Lighting.NotRetro)
60724 {
60725 if (bgColorToSet.R < 20)
60726 {
60727 bgColorToSet.R = 20;
60728 }
60729 if (bgColorToSet.G < 14)
60730 {
60731 bgColorToSet.G = 14;
60732 }
60733 if (bgColorToSet.B < 6)
60734 {
60735 bgColorToSet.B = 6;
60736 }
60737 }
60738 }
60739 if ((remixWorld && !gameMenu) || WorldGen.remixWorldGen)
60740 {
60741 bgColorToSet.R = 1;
60742 bgColorToSet.G = 1;
60743 bgColorToSet.B = 1;
60744 }
60745 if (lightning > 0f)
60746 {
60747 float value = (float)(int)bgColorToSet.R / 255f;
60748 float value2 = (float)(int)bgColorToSet.G / 255f;
60749 float value3 = (float)(int)bgColorToSet.B / 255f;
60753 bgColorToSet.R = (byte)(value * 255f);
60754 bgColorToSet.G = (byte)(value2 * 255f);
60755 bgColorToSet.B = (byte)(value3 * 255f);
60756 }
60757 if (!info.BloodMoonActive)
60758 {
60760 }
60762 }
static float Lerp(float value1, float value2, float amount)
Definition MathHelper.cs:53
static void ModifyNightColor(ref Color bgColorToSet, ref Color moonColor)
static void FixBiomeDarkness(ref Color bgColor, ref int R, ref int G, ref int B)
static void ModifyMinimumLightColorAtNight(ref byte minimalLight)
static Microsoft.Xna.Framework.Color ColorOfTheSkies
Definition Main.cs:2577
static double time
Definition Main.cs:1284
static MoonPhase GetMoonPhase()
Definition Main.cs:3058
static float cloudAlpha
Definition Main.cs:1302
static float lightning
Definition Main.cs:2555
static bool dayTime
Definition Main.cs:1282
static float atmo
Definition Main.cs:2571
static bool eclipse
Definition Main.cs:1312
static bool dontStarveWorld
Definition Main.cs:345
static float eclipseLight
Definition Main.cs:1314
static bool gameMenu
Definition Main.cs:1926
static bool remixWorld
Definition Main.cs:349

References Terraria.Main.atmo, Terraria.Main.cloudAlpha, Terraria.Main.ColorOfTheSkies, Terraria.Main.dayTime, Terraria.Main.dontStarveWorld, Terraria.Main.eclipse, Terraria.Main.eclipseLight, Terraria.GameContent.DontStarveSeed.FixBiomeDarkness(), System.G, Terraria.Main.gameMenu, Terraria.Main.GetMoonPhase(), System.info, Microsoft.Xna.Framework.MathHelper.Lerp(), Terraria.Main.lightning, Terraria.GameContent.DontStarveSeed.ModifyMinimumLightColorAtNight(), Terraria.GameContent.DontStarveSeed.ModifyNightColor(), Terraria.Lighting.NotRetro, Terraria.Main.remixWorld, Terraria.WorldGen.remixWorldGen, Terraria.Main.time, System.value, and Microsoft.Xna.Framework.Color.White.

Referenced by Terraria.Main.DoDraw(), and Terraria.Main.DrawCapture().