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

◆ DrawSunAndMoon()

void Terraria.Main.DrawSunAndMoon ( SceneArea sceneArea,
Color moonColor,
Color sunColor,
float tempMushroomInfluence )
inlineprivate

Definition at line 79659 of file Main.cs.

79660 {
79661 //IL_0835: Unknown result type (might be due to invalid IL or missing references)
79662 //IL_07c5: Unknown result type (might be due to invalid IL or missing references)
79663 //IL_04fd: Unknown result type (might be due to invalid IL or missing references)
79664 //IL_0500: Unknown result type (might be due to invalid IL or missing references)
79665 //IL_0505: Unknown result type (might be due to invalid IL or missing references)
79666 //IL_0513: Unknown result type (might be due to invalid IL or missing references)
79667 //IL_0519: Unknown result type (might be due to invalid IL or missing references)
79668 //IL_051e: Unknown result type (might be due to invalid IL or missing references)
79669 //IL_0523: Unknown result type (might be due to invalid IL or missing references)
79670 //IL_083a: Unknown result type (might be due to invalid IL or missing references)
79671 //IL_083f: Unknown result type (might be due to invalid IL or missing references)
79672 //IL_084b: Unknown result type (might be due to invalid IL or missing references)
79673 //IL_053b: Unknown result type (might be due to invalid IL or missing references)
79674 //IL_0553: Unknown result type (might be due to invalid IL or missing references)
79675 //IL_055d: Unknown result type (might be due to invalid IL or missing references)
79676 //IL_0586: Unknown result type (might be due to invalid IL or missing references)
79677 //IL_05b3: Unknown result type (might be due to invalid IL or missing references)
79678 //IL_05da: Unknown result type (might be due to invalid IL or missing references)
79679 //IL_05e4: Unknown result type (might be due to invalid IL or missing references)
79680 //IL_0601: Unknown result type (might be due to invalid IL or missing references)
79681 //IL_08ac: Unknown result type (might be due to invalid IL or missing references)
79682 //IL_062e: Unknown result type (might be due to invalid IL or missing references)
79683 //IL_0655: Unknown result type (might be due to invalid IL or missing references)
79684 //IL_065f: Unknown result type (might be due to invalid IL or missing references)
79685 //IL_067c: Unknown result type (might be due to invalid IL or missing references)
79686 //IL_06f3: Unknown result type (might be due to invalid IL or missing references)
79687 //IL_0720: Unknown result type (might be due to invalid IL or missing references)
79688 //IL_072a: Unknown result type (might be due to invalid IL or missing references)
79689 //IL_074b: Unknown result type (might be due to invalid IL or missing references)
79690 //IL_06a8: Unknown result type (might be due to invalid IL or missing references)
79691 //IL_06b8: Unknown result type (might be due to invalid IL or missing references)
79692 //IL_06c2: Unknown result type (might be due to invalid IL or missing references)
79693 //IL_06ce: Unknown result type (might be due to invalid IL or missing references)
79694 //IL_0451: Unknown result type (might be due to invalid IL or missing references)
79695 //IL_045b: Unknown result type (might be due to invalid IL or missing references)
79696 //IL_0460: Unknown result type (might be due to invalid IL or missing references)
79697 //IL_046e: Unknown result type (might be due to invalid IL or missing references)
79698 //IL_0474: Unknown result type (might be due to invalid IL or missing references)
79699 //IL_0479: Unknown result type (might be due to invalid IL or missing references)
79700 //IL_047e: Unknown result type (might be due to invalid IL or missing references)
79701 //IL_0486: Unknown result type (might be due to invalid IL or missing references)
79702 //IL_0492: Unknown result type (might be due to invalid IL or missing references)
79703 //IL_0496: Unknown result type (might be due to invalid IL or missing references)
79704 //IL_04ab: Unknown result type (might be due to invalid IL or missing references)
79705 //IL_04b7: Unknown result type (might be due to invalid IL or missing references)
79706 //IL_04bb: Unknown result type (might be due to invalid IL or missing references)
79707 //IL_08ea: Unknown result type (might be due to invalid IL or missing references)
79708 Texture2D value = TextureAssets.Sun.Value;
79709 int num = moonType;
79710 if (!TextureAssets.Moon.IndexInRange(num))
79711 {
79712 num = Utils.Clamp(num, 0, 8);
79713 }
79714 Texture2D value2 = TextureAssets.Moon[num].Value;
79715 int num6 = sceneArea.bgTopY;
79716 int num7 = (int)(time / 54000.0 * (double)(sceneArea.totalWidth + (float)(value.Width * 2))) - value.Width;
79717 int num8 = 0;
79718 float num9 = 1f;
79719 float rotation = (float)(time / 54000.0) * 2f - 7.3f;
79720 int num10 = (int)(time / 32400.0 * (double)(sceneArea.totalWidth + (float)(value2.Width * 2))) - value2.Width;
79721 int num11 = 0;
79722 float num12 = 1f;
79723 float num13 = (float)(time / 32400.0) * 2f - 7.3f;
79724 if (dayTime)
79725 {
79726 double num2;
79727 if (time < 27000.0)
79728 {
79729 num2 = Math.Pow(1.0 - time / 54000.0 * 2.0, 2.0);
79730 num8 = (int)((double)num6 + num2 * 250.0 + 180.0);
79731 }
79732 else
79733 {
79734 num2 = Math.Pow((time / 54000.0 - 0.5) * 2.0, 2.0);
79735 num8 = (int)((double)num6 + num2 * 250.0 + 180.0);
79736 }
79737 num9 = (float)(1.2 - num2 * 0.4);
79738 }
79739 else
79740 {
79741 double num3;
79742 if (time < 16200.0)
79743 {
79744 num3 = Math.Pow(1.0 - time / 32400.0 * 2.0, 2.0);
79745 num11 = (int)((double)num6 + num3 * 250.0 + 180.0);
79746 }
79747 else
79748 {
79749 num3 = Math.Pow((time / 32400.0 - 0.5) * 2.0, 2.0);
79750 num11 = (int)((double)num6 + num3 * 250.0 + 180.0);
79751 }
79752 num12 = (float)(1.2 - num3 * 0.4);
79753 }
79756 if (starGame)
79757 {
79758 if (WorldGen.generatingWorld)
79759 {
79761 if (rand.Next(60) == 0)
79762 {
79763 for (int i = 0; i < numStars; i++)
79764 {
79765 if (star[i].hidden)
79766 {
79767 Star.SpawnStars(i);
79768 }
79769 }
79770 }
79771 if (dayTime)
79772 {
79773 dayTime = false;
79774 time = 0.0;
79775 }
79776 }
79777 else
79778 {
79779 starGame = false;
79780 }
79781 }
79782 else
79783 {
79784 starsHit = 0;
79785 }
79786 if (dayTime)
79787 {
79788 if ((remixWorld && !gameMenu) || WorldGen.remixWorldGen)
79789 {
79790 return;
79791 }
79792 num9 *= 1.1f;
79793 float num4 = 1f - tempMushroomInfluence;
79794 num4 -= cloudAlpha * 1.5f * atmo;
79795 if (num4 < 0f)
79796 {
79797 num4 = 0f;
79798 }
79799 Color color = default(Color);
79800 ((Color)(ref color))._002Ector((int)(byte)(255f * num4), (int)(byte)((float)(int)((Color)(ref sunColor)).G * num4), (int)(byte)((float)(int)((Color)(ref sunColor)).B * num4), (int)(byte)(255f * num4));
79801 Color color2 = default(Color);
79802 ((Color)(ref color2))._002Ector((int)(byte)((float)(int)((Color)(ref sunColor)).R * num4), (int)(byte)((float)(int)((Color)(ref sunColor)).G * num4), (int)(byte)((float)(int)((Color)(ref sunColor)).B * num4), (int)(byte)((float)(int)((Color)(ref sunColor)).B * num4));
79803 bool flag = false;
79804 if (eclipse)
79805 {
79806 value = TextureAssets.Sun3.Value;
79807 flag = true;
79808 }
79809 else if (!gameMenu && player[myPlayer].head == 12)
79810 {
79811 value = TextureAssets.Sun2.Value;
79812 flag = true;
79813 }
79814 if (flag)
79815 {
79816 ((Color)(ref color2))._002Ector((int)(byte)((float)(int)((Color)(ref sunColor)).R * num4), (int)(byte)((float)(int)((Color)(ref sunColor)).G * num4), (int)(byte)((float)(int)((Color)(ref sunColor)).B * num4), (int)(byte)((float)(((Color)(ref sunColor)).B - 60) * num4));
79817 }
79818 Vector2 origin = value.Size() / 2f;
79819 Vector2 position = new Vector2((float)num7, (float)(num8 + sunModY)) + sceneArea.SceneLocalScreenPositionOffset;
79820 spriteBatch.Draw(value, position, (Rectangle?)null, color, rotation, origin, num9, (SpriteEffects)0, 0f);
79821 spriteBatch.Draw(value, position, (Rectangle?)null, color2, rotation, origin, num9, (SpriteEffects)0, 0f);
79822 }
79823 if (!dayTime)
79824 {
79825 float num5 = 1f - cloudAlpha * 1.5f * atmo;
79826 if (num5 < 0f)
79827 {
79828 num5 = 0f;
79829 }
79830 moonColor *= num5;
79831 Vector2 position2 = new Vector2((float)num10, (float)(num11 + moonModY)) + sceneArea.SceneLocalScreenPositionOffset;
79832 if (WorldGen.drunkWorldGen)
79833 {
79834 spriteBatch.Draw(TextureAssets.SmileyMoon.Value, position2, (Rectangle?)new Rectangle(0, 0, TextureAssets.SmileyMoon.Width(), TextureAssets.SmileyMoon.Height()), moonColor, num13 / 2f + (float)Math.PI, new Vector2((float)(TextureAssets.SmileyMoon.Width() / 2), (float)(TextureAssets.SmileyMoon.Width() / 2)), num12, (SpriteEffects)0, 0f);
79835 }
79836 else if (pumpkinMoon)
79837 {
79838 spriteBatch.Draw(TextureAssets.PumpkinMoon.Value, position2, (Rectangle?)new Rectangle(0, TextureAssets.PumpkinMoon.Width() * moonPhase, TextureAssets.PumpkinMoon.Width(), TextureAssets.PumpkinMoon.Width()), moonColor, num13, new Vector2((float)(TextureAssets.PumpkinMoon.Width() / 2), (float)(TextureAssets.PumpkinMoon.Width() / 2)), num12, (SpriteEffects)0, 0f);
79839 }
79840 else if (snowMoon)
79841 {
79842 spriteBatch.Draw(TextureAssets.SnowMoon.Value, position2, (Rectangle?)new Rectangle(0, TextureAssets.SnowMoon.Width() * moonPhase, TextureAssets.SnowMoon.Width(), TextureAssets.SnowMoon.Width()), moonColor, num13, new Vector2((float)(TextureAssets.SnowMoon.Width() / 2), (float)(TextureAssets.SnowMoon.Width() / 2)), num12, (SpriteEffects)0, 0f);
79843 }
79844 else if (value2 != TextureAssets.Moon[num].Value)
79845 {
79846 spriteBatch.Draw(value2, position2, (Rectangle?)new Rectangle(0, 0, value2.Width, value2.Width), moonColor, num13, new Vector2((float)(value2.Width / 2)), num12, (SpriteEffects)0, 0f);
79847 }
79848 else
79849 {
79850 spriteBatch.Draw(TextureAssets.Moon[num].Value, position2, (Rectangle?)new Rectangle(0, TextureAssets.Moon[num].Width() * moonPhase, TextureAssets.Moon[num].Width(), TextureAssets.Moon[num].Width()), moonColor, num13, new Vector2((float)(TextureAssets.Moon[num].Width() / 2), (float)(TextureAssets.Moon[num].Width() / 2)), num12, (SpriteEffects)0, 0f);
79851 }
79852 }
79853 Rectangle value3 = ((!dayTime) ? new Rectangle((int)((double)num10 - (double)TextureAssets.Moon[num].Width() * 0.5 * (double)num12), (int)((double)num11 - (double)TextureAssets.Moon[num].Width() * 0.5 * (double)num12 + (double)moonModY), (int)((float)TextureAssets.Moon[num].Width() * num12), (int)((float)TextureAssets.Moon[num].Width() * num12)) : new Rectangle((int)((double)num7 - (double)TextureAssets.Sun.Width() * 0.5 * (double)num9), (int)((double)num8 - (double)TextureAssets.Sun.Height() * 0.5 * (double)num9 + (double)sunModY), (int)((float)TextureAssets.Sun.Width() * num9), (int)((float)TextureAssets.Sun.Width() * num9)));
79854 ((Rectangle)(ref value3)).Offset((int)sceneArea.SceneLocalScreenPositionOffset.X, (int)sceneArea.SceneLocalScreenPositionOffset.Y);
79855 Rectangle rectangle = default(Rectangle);
79856 ((Rectangle)(ref rectangle))._002Ector(mouseX, mouseY, 1, 1);
79857 sunModY = (short)((double)sunModY * 0.999);
79858 moonModY = (short)((double)moonModY * 0.999);
79859 if (!gameMenu || netMode == 1)
79860 {
79861 return;
79862 }
79863 if (((Rectangle)(ref rectangle)).Intersects(value3) || alreadyGrabbingSunOrMoon)
79864 {
79865 player[myPlayer].mouseInterface = true;
79866 }
79867 if ((mouseLeft || starGame) && hasFocus)
79868 {
79869 if (!((Rectangle)(ref rectangle)).Intersects(value3) && !alreadyGrabbingSunOrMoon)
79870 {
79871 return;
79872 }
79873 if (dayTime)
79874 {
79875 time = 54000.0 * (double)((float)(mouseX + TextureAssets.Sun.Width()) / ((float)screenWidth + (float)(TextureAssets.Sun.Width() * 2)));
79876 sunModY = (short)(mouseY - num8);
79877 if (time > 53990.0)
79878 {
79879 time = 53990.0;
79880 }
79881 }
79882 else
79883 {
79884 time = 32400.0 * (double)((float)(mouseX + TextureAssets.Moon[num].Width()) / ((float)screenWidth + (float)(TextureAssets.Moon[num].Width() * 2)));
79885 moonModY = (short)(mouseY - num11);
79886 if (time > 32390.0)
79887 {
79888 time = 32390.0;
79889 }
79890 }
79891 if (time < 10.0)
79892 {
79893 time = 10.0;
79894 }
79896 }
79897 else
79898 {
79900 }
79901 }
static Asset< Texture2D > Sun3
static Asset< Texture2D > SmileyMoon
static Asset< Texture2D > Sun
static Asset< Texture2D > Sun2
static Asset< Texture2D > PumpkinMoon
static Asset< Texture2D > SnowMoon
static Asset< Texture2D >[] Moon
static double time
The time that has passed since it last became day/night. Increased by F:Terraria....
Definition Main.cs:1375
static Star[] star
Definition Main.cs:1824
static int numStars
Definition Main.cs:1445
static float cloudAlpha
Definition Main.cs:1393
static SpriteBatch spriteBatch
Definition Main.cs:1043
static int myPlayer
The index in F:Terraria.Main.player of this client's Player. If this is 255, this client is the ser...
Definition Main.cs:1958
static int netMode
Denotes the current network mode: 0 for single player client, 1 for multiplayer client,...
Definition Main.cs:2182
static bool starGame
Definition Main.cs:2680
static bool hasFocus
Definition Main.cs:1934
static bool dayTime
Definition Main.cs:1365
static short moonModY
Definition Main.cs:1383
static int moonPhase
Definition Main.cs:1379
static float atmo
Definition Main.cs:2654
static int starsHit
Definition Main.cs:2682
static bool eclipse
Definition Main.cs:1403
static bool alreadyGrabbingSunOrMoon
Definition Main.cs:1385
static int moonType
Definition Main.cs:1494
static UnifiedRandom rand
Definition Main.cs:2758
static int screenWidth
Definition Main.cs:1868
static short sunModY
Definition Main.cs:1381
static bool snowMoon
Definition Main.cs:1391
static bool pumpkinMoon
Definition Main.cs:1389
static int mouseY
Definition Main.cs:634
static bool gameMenu
Definition Main.cs:2076
static Player[] player
Definition Main.cs:1960
static int mouseX
Definition Main.cs:632
static float ForcedMinimumZoom
Definition Main.cs:253
static bool remixWorld
Definition Main.cs:377
static bool mouseLeft
Definition Main.cs:642

References Terraria.Main.alreadyGrabbingSunOrMoon, Terraria.Main.atmo, Terraria.Main.cloudAlpha, Terraria.Graphics.Light.Color, Terraria.Main.dayTime, Terraria.WorldGen.drunkWorldGen, Terraria.Main.eclipse, Terraria.Main.ForcedMinimumZoom, Terraria.Main.gameMenu, Terraria.WorldGen.generatingWorld, Terraria.Main.hasFocus, Terraria.GameContent.TextureAssets.Moon, Terraria.Main.moonModY, Terraria.Main.moonPhase, Terraria.Main.moonType, Terraria.Main.mouseLeft, Terraria.Main.mouseX, Terraria.Main.mouseY, Terraria.Main.myPlayer, Terraria.Main.netMode, Terraria.Main.numStars, Terraria.Main.player, Terraria.GameContent.TextureAssets.PumpkinMoon, Terraria.Main.pumpkinMoon, Terraria.Main.rand, Terraria.Main.remixWorld, Terraria.WorldGen.remixWorldGen, Terraria.Main.screenWidth, Terraria.GameContent.TextureAssets.SmileyMoon, Terraria.GameContent.TextureAssets.SnowMoon, Terraria.Main.snowMoon, Terraria.Star.SpawnStars(), Terraria.Main.spriteBatch, Terraria.Main.star, Terraria.Main.starGame, Terraria.Main.starsHit, Terraria.GameContent.TextureAssets.Sun, Terraria.GameContent.TextureAssets.Sun2, Terraria.GameContent.TextureAssets.Sun3, Terraria.Main.sunModY, and Terraria.Main.time.

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

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