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

◆ DrawBackground()

void Terraria.Main.DrawBackground ( )
inlineprotected

Definition at line 49686 of file Main.cs.

49687 {
49688 float num = shimmerAlpha;
49689 if (num == 1f)
49690 {
49691 ugBackTransition = 0f;
49692 return;
49693 }
49694 if (!BackgroundEnabled)
49695 {
49697 return;
49698 }
49701 stopwatch.Start();
49702 double num2 = maxTilesY - 330;
49703 double num3 = (int)((num2 - worldSurface) / 6.0) * 6;
49704 num2 = worldSurface + num3 - 5.0;
49705 int num4 = (int)(255f * (1f - gfxQuality) + 140f * gfxQuality);
49706 int num5 = (int)(200f * (1f - gfxQuality) + 40f * gfxQuality);
49707 int num6 = 128;
49709 Vector3 vector2 = new Vector3(0.9f);
49710 float num7 = MathHelper.Clamp((screenPosition.Y - (float)worldSurface * 16f) / 300f, 0f, 1f);
49711 float globalBrightness = Lighting.GlobalBrightness;
49712 Lighting.GlobalBrightness = globalBrightness * (1f - num7) + 1f * num7;
49713 float value = (float)((double)(screenPosition.Y - (float)(screenHeight / 2) + 200f) - rockLayer * 16.0) / 300f;
49714 value = MathHelper.Clamp(value, 0f, 1f);
49715 int num8 = (int)((screenPosition.X + (float)(screenWidth / 2)) / 16f);
49716 int num9 = 3;
49717 num9 = ((num8 <= caveBackX[0]) ? caveBackStyle[0] : ((num8 <= caveBackX[1]) ? caveBackStyle[1] : ((num8 > caveBackX[2]) ? caveBackStyle[3] : caveBackStyle[2])));
49718 num9 += 3;
49719 if (SceneMetrics.SnowTileCount > SceneMetrics.SnowTileThreshold && (screenPosition.Y + (float)screenHeight + 1200f) / 16f < (float)(maxTilesY - 250))
49720 {
49721 num9 = 1;
49722 }
49723 if (SceneMetrics.JungleTileCount > SceneMetrics.JungleTileThreshold)
49724 {
49725 if (num9 == 1)
49726 {
49727 if (SceneMetrics.JungleTileCount > SceneMetrics.SnowTileCount)
49728 {
49729 num9 = 11;
49730 }
49731 }
49732 else
49733 {
49734 num9 = 11;
49735 }
49736 }
49737 if (WorldGen.oceanDepths((int)(screenPosition.X + (float)(screenHeight / 2)) / 16, (int)(screenPosition.Y + (float)(screenHeight / 2)) / 16))
49738 {
49739 num9 = (player[myPlayer].ZoneCorrupt ? 19 : (player[myPlayer].ZoneCrimson ? 21 : ((!player[myPlayer].ZoneHallow) ? 18 : 20)));
49740 }
49741 else if ((double)(screenPosition.Y / 16f) > rockLayer + 60.0 && (double)(screenPosition.Y / 16f) < num2 - 60.0)
49742 {
49743 if (player[myPlayer].ZoneSnow)
49744 {
49745 if (player[myPlayer].ZoneCorrupt)
49746 {
49747 num9 = 15;
49748 }
49749 else if (player[myPlayer].ZoneCrimson)
49750 {
49751 num9 = 16;
49752 }
49753 else if (player[myPlayer].ZoneHallow)
49754 {
49755 num9 = 17;
49756 }
49757 }
49758 else if (player[myPlayer].ZoneCorrupt)
49759 {
49760 num9 = 12;
49761 }
49762 else if (player[myPlayer].ZoneCrimson)
49763 {
49764 num9 = 13;
49765 }
49766 else if (player[myPlayer].ZoneHallow)
49767 {
49768 num9 = 14;
49769 }
49770 }
49771 if (player[myPlayer].ZoneGlowshroom)
49772 {
49773 num9 = 2;
49774 }
49776 {
49779 ugBackTransition = 1f;
49780 }
49781 if (num > 0f)
49782 {
49783 ugBackTransition = 0f;
49784 }
49785 if (ugBackTransition > 0f)
49786 {
49787 ugBackTransition -= 0.25f;
49788 }
49789 if (ugBackTransition < 0f)
49790 {
49791 ugBackTransition = 0f;
49792 }
49793 int[] array = new int[7];
49794 int[] array2 = new int[7];
49795 for (int i = 0; i < 2; i++)
49796 {
49798 if (i == 1)
49799 {
49801 }
49802 int[] array3 = new int[7];
49803 switch (num10)
49804 {
49805 case 0:
49806 array3[0] = 1;
49807 array3[1] = 2;
49808 array3[2] = 4;
49809 array3[3] = 3;
49810 array3[4] = 6;
49811 array3[5] = 5;
49812 break;
49813 case 1:
49814 if (iceBackStyle == 0)
49815 {
49816 array3[1] = 33;
49817 array3[3] = 32;
49818 array3[0] = 40;
49819 array3[2] = 34;
49820 }
49821 else if (iceBackStyle == 1)
49822 {
49823 array3[1] = 118;
49824 array3[3] = 117;
49825 array3[0] = 160;
49826 array3[2] = 161;
49827 }
49828 else if (iceBackStyle == 2)
49829 {
49830 array3[1] = 165;
49831 array3[3] = 167;
49832 array3[0] = 164;
49833 array3[2] = 166;
49834 }
49835 else
49836 {
49837 array3[1] = 120;
49838 array3[3] = 119;
49839 array3[0] = 162;
49840 array3[2] = 163;
49841 }
49842 array3[4] = 128 + hellBackStyle;
49843 break;
49844 case 2:
49845 array3[0] = 62;
49846 array3[1] = 63;
49847 array3[2] = 64;
49848 array3[3] = 65;
49849 array3[4] = 143 + hellBackStyle;
49850 break;
49851 case 3:
49852 array3[0] = 66;
49853 array3[1] = 67;
49854 array3[2] = 68;
49855 array3[3] = 69;
49856 array3[4] = 128 + hellBackStyle;
49857 break;
49858 case 4:
49859 array3[0] = 70;
49860 array3[1] = 71;
49861 array3[2] = 68;
49862 array3[3] = 72;
49863 array3[4] = 128 + hellBackStyle;
49864 break;
49865 case 5:
49866 array3[0] = 73;
49867 array3[1] = 74;
49868 array3[2] = 75;
49869 array3[3] = 76;
49870 array3[4] = 131 + hellBackStyle;
49871 break;
49872 case 6:
49873 array3[0] = 77;
49874 array3[1] = 78;
49875 array3[2] = 79;
49876 array3[3] = 80;
49877 array3[4] = 134 + hellBackStyle;
49878 break;
49879 case 7:
49880 array3[0] = 77;
49881 array3[1] = 81;
49882 array3[2] = 79;
49883 array3[3] = 82;
49884 array3[4] = 134 + hellBackStyle;
49885 break;
49886 case 8:
49887 array3[0] = 83;
49888 array3[1] = 84;
49889 array3[2] = 85;
49890 array3[3] = 86;
49891 array3[4] = 137 + hellBackStyle;
49892 break;
49893 case 9:
49894 array3[0] = 83;
49895 array3[1] = 87;
49896 array3[2] = 88;
49897 array3[3] = 89;
49898 array3[4] = 137 + hellBackStyle;
49899 break;
49900 case 10:
49901 array3[0] = 121;
49902 array3[1] = 122;
49903 array3[2] = 123;
49904 array3[3] = 124;
49905 array3[4] = 140 + hellBackStyle;
49906 break;
49907 case 11:
49908 if (jungleBackStyle == 0)
49909 {
49910 array3[0] = 153;
49911 array3[1] = 147;
49912 array3[2] = 148;
49913 array3[3] = 149;
49914 array3[4] = 150 + hellBackStyle;
49915 }
49916 else
49917 {
49918 array3[0] = 146;
49919 array3[1] = 154;
49920 array3[2] = 155;
49921 array3[3] = 156;
49922 array3[4] = 157 + hellBackStyle;
49923 }
49924 break;
49925 case 12:
49926 case 13:
49927 case 14:
49928 array3[0] = 66;
49929 array3[1] = 67;
49930 array3[2] = 68;
49931 array3[4] = 128 + hellBackStyle;
49932 switch (num10)
49933 {
49934 case 12:
49935 array3[3] = 193 + worldID % 4;
49936 break;
49937 case 13:
49938 array3[3] = 188 + worldID % 5;
49939 break;
49940 case 14:
49941 array3[3] = 197 + worldID % 3;
49942 break;
49943 }
49944 break;
49945 default:
49946 if (num10 >= 15 && num10 <= 17)
49947 {
49948 array3[0] = 40;
49949 array3[1] = 33;
49950 array3[2] = 34;
49951 array3[4] = 128 + hellBackStyle;
49952 switch (num10)
49953 {
49954 case 15:
49955 array3[3] = 200;
49956 break;
49957 case 16:
49958 array3[3] = 201 + worldID % 2;
49959 break;
49960 case 17:
49961 array3[3] = 203 + worldID % 4;
49962 break;
49963 }
49964 break;
49965 }
49966 switch (num10)
49967 {
49968 case 18:
49969 array3[0] = 290;
49970 array3[1] = 291;
49971 break;
49972 case 19:
49973 array3[0] = 292;
49974 array3[1] = 293;
49975 break;
49976 case 20:
49977 array3[0] = 294;
49978 array3[1] = 295;
49979 break;
49980 case 21:
49981 array3[0] = 296;
49982 array3[1] = 297;
49983 break;
49984 }
49985 break;
49986 }
49987 if (hellBackStyle == 0)
49988 {
49989 array3[5] = 125;
49990 }
49991 if (hellBackStyle == 1)
49992 {
49993 array3[5] = 126;
49994 }
49995 if (hellBackStyle == 2)
49996 {
49997 array3[5] = 127;
49998 }
49999 array3[6] = 185 + hellBackStyle;
50007 if (i == 0)
50008 {
50009 for (int j = 0; j < 7; j++)
50010 {
50011 array[j] = array3[j];
50012 }
50013 }
50014 else
50015 {
50016 for (int k = 0; k < 7; k++)
50017 {
50018 array2[k] = array3[k];
50019 }
50020 }
50021 }
50022 globalBrightness = 1.2f - 0.2f * value;
50023 float x = vector2.X;
50024 float y = vector2.Y;
50025 float z = vector2.Z;
50026 num6 = TextureAssets.Background[array[0]].Width() - 32;
50028 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50029 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50030 bgTopY = (int)((float)((int)worldSurface * 16 - 16) - screenPosition.Y + 16f);
50031 for (int l = 0; l < bgLoops; l++)
50032 {
50033 for (int m = 0; m < num6 / 16; m++)
50034 {
50035 int num11 = (int)(float)Math.Round(0f - (float)Math.IEEERemainder((float)bgStartX + screenPosition.X, 16.0));
50036 if (num11 == -8)
50037 {
50038 num11 = 8;
50039 }
50040 float num12 = bgStartX + num6 * l + m * 16 + 8;
50041 float num13 = bgTopY;
50042 Microsoft.Xna.Framework.Color color = Lighting.GetColor((int)((num12 + screenPosition.X) / 16f), (int)((screenPosition.Y + num13) / 16f));
50043 color.R = (byte)((float)(int)color.R * x);
50044 color.G = (byte)((float)(int)color.G * y);
50045 color.B = (byte)((float)(int)color.B * z);
50046 if (num > 0f)
50047 {
50048 color *= 1f - num;
50049 }
50050 spriteBatch.Draw(TextureAssets.Background[array[0]].Value, new Vector2(bgStartX + num6 * l + 16 * m + num11, bgTopY) + vector, new Microsoft.Xna.Framework.Rectangle(16 * m + num11 + 16, 0, 16, 16), color);
50051 }
50052 }
50053 if (ugBackTransition > 0f)
50054 {
50055 num6 = TextureAssets.Background[array2[0]].Width() - 32;
50056 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50057 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50058 for (int n = 0; n < bgLoops; n++)
50059 {
50060 for (int num14 = 0; num14 < num6 / 16; num14++)
50061 {
50062 int num15 = (int)(float)Math.Round(0f - (float)Math.IEEERemainder((float)bgStartX + screenPosition.X, 16.0));
50063 if (num15 == -8)
50064 {
50065 num15 = 8;
50066 }
50067 float num16 = bgStartX + num6 * n + num14 * 16 + 8;
50068 float num17 = bgTopY;
50069 Microsoft.Xna.Framework.Color color2 = Lighting.GetColor((int)((num16 + screenPosition.X) / 16f), (int)((screenPosition.Y + num17) / 16f));
50070 color2.R = (byte)((float)(int)color2.R * x);
50071 color2.G = (byte)((float)(int)color2.G * y);
50072 color2.B = (byte)((float)(int)color2.B * z);
50074 color3.R = (byte)((float)(int)color3.R * ugBackTransition);
50075 color3.G = (byte)((float)(int)color3.G * ugBackTransition);
50076 color3.B = (byte)((float)(int)color3.B * ugBackTransition);
50077 color3.A = (byte)((float)(int)color3.A * ugBackTransition);
50078 spriteBatch.Draw(TextureAssets.Background[array2[0]].Value, new Vector2(bgStartX + num6 * n + 16 * num14 + num15, bgTopY) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num14 + num15 + 16, 0, 16, 16), color3);
50079 }
50080 }
50081 }
50082 bool flag = false;
50083 bool flag2 = false;
50084 bgTopY = (int)((float)((int)worldSurface * 16) - screenPosition.Y + 16f);
50085 if (worldSurface * 16.0 <= (double)(screenPosition.Y + (float)screenHeight + (float)offScreenRange))
50086 {
50088 num6 = TextureAssets.Background[array[1]].Width() - 32;
50089 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50090 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50091 if (worldSurface * 16.0 < (double)(screenPosition.Y - 16f))
50092 {
50094 bgLoopsY = (screenHeight - bgStartY + (int)vector.Y * 2) / backgroundHeight[2] + 1;
50095 }
50096 else
50097 {
50098 bgStartY = bgTopY;
50099 bgLoopsY = (screenHeight - bgTopY + (int)vector.Y * 2) / backgroundHeight[2] + 1;
50100 }
50101 if (rockLayer * 16.0 < (double)(Camera.ScaledPosition.Y + 600f))
50102 {
50103 bgLoopsY = (int)(rockLayer * 16.0 - (double)screenPosition.Y + 600.0 - (double)bgStartY) / backgroundHeight[2];
50104 flag2 = true;
50105 }
50106 int num18 = (int)(float)Math.Round(0f - (float)Math.IEEERemainder((float)bgStartX + screenPosition.X, 16.0));
50107 if (num18 == -8)
50108 {
50109 num18 = 8;
50110 }
50111 for (int num19 = 0; num19 < bgLoops; num19++)
50112 {
50113 for (int num20 = 0; num20 < bgLoopsY; num20++)
50114 {
50115 for (int num21 = 0; num21 < num6 / 16; num21++)
50116 {
50117 for (int num22 = 0; num22 < 6; num22++)
50118 {
50119 float num23 = bgStartY + num20 * 96 + num22 * 16 + 8;
50120 int num24 = (int)(((float)(bgStartX + num6 * num19 + num21 * 16 + 8) + screenPosition.X) / 16f);
50121 int num25 = (int)((num23 + screenPosition.Y) / 16f);
50122 Microsoft.Xna.Framework.Color color4 = Lighting.GetColor(num24, num25);
50123 if (!WorldGen.InWorld(num24, num25))
50124 {
50125 continue;
50126 }
50127 if (tile[num24, num25] == null)
50128 {
50129 tile[num24, num25] = new Tile();
50130 }
50131 if (num == 0f && (color4.R > 0 || color4.G > 0 || color4.B > 0))
50132 {
50133 if (!drawToScreen)
50134 {
50135 Lighting.GetCornerColors(num24, num25, out var vertices);
50136 vertices.BottomLeftColor = new Microsoft.Xna.Framework.Color(vertices.BottomLeftColor.ToVector3() * vector2);
50137 vertices.BottomRightColor = new Microsoft.Xna.Framework.Color(vertices.BottomRightColor.ToVector3() * vector2);
50138 tileBatch.Draw(TextureAssets.Background[array[1]].Value, new Vector2(bgStartX + num6 * num19 + 16 * num21 + num18, bgStartY + backgroundHeight[array2[1]] * num20 + 16 * num22) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num21 + num18 + 16, 16 * num22, 16, 16), vertices, Vector2.Zero, 1f, SpriteEffects.None);
50139 }
50140 else if ((color4.R > num4 || (double)(int)color4.G > (double)num4 * 1.1 || (double)(int)color4.B > (double)num4 * 1.2) && !tile[num24, num25].active() && WallLightAt(num24, num25) && ugBackTransition == 0f)
50141 {
50142 Lighting.GetColor9Slice(num24, num25, ref slices);
50143 try
50144 {
50145 for (int num26 = 0; num26 < 9; num26++)
50146 {
50147 int num27 = 0;
50148 int num28 = 0;
50149 int width = 4;
50150 int height = 4;
50153 switch (num26)
50154 {
50155 case 0:
50156 if (!tile[num24 - 1, num25 - 1].active())
50157 {
50158 color6 = slices[num26];
50159 }
50160 break;
50161 case 1:
50162 width = 8;
50163 num27 = 4;
50164 if (!tile[num24, num25 - 1].active())
50165 {
50166 color6 = slices[num26];
50167 }
50168 break;
50169 case 2:
50170 num27 = 12;
50171 if (!tile[num24 + 1, num25 - 1].active())
50172 {
50173 color6 = slices[num26];
50174 }
50175 break;
50176 case 3:
50177 height = 8;
50178 num28 = 4;
50179 if (!tile[num24 - 1, num25].active())
50180 {
50181 color6 = slices[num26];
50182 }
50183 break;
50184 case 4:
50185 width = 8;
50186 height = 8;
50187 num27 = 4;
50188 num28 = 4;
50189 break;
50190 case 5:
50191 num27 = 12;
50192 num28 = 4;
50193 height = 8;
50194 if (!tile[num24 + 1, num25].active())
50195 {
50196 color6 = slices[num26];
50197 }
50198 break;
50199 case 6:
50200 num28 = 12;
50201 if (!tile[num24 - 1, num25 + 1].active())
50202 {
50203 color6 = slices[num26];
50204 }
50205 break;
50206 case 7:
50207 width = 8;
50208 height = 4;
50209 num27 = 4;
50210 num28 = 12;
50211 if (!tile[num24, num25 + 1].active())
50212 {
50213 color6 = slices[num26];
50214 }
50215 break;
50216 case 8:
50217 num27 = 12;
50218 num28 = 12;
50219 if (!tile[num24 + 1, num25 + 1].active())
50220 {
50221 color6 = slices[num26];
50222 }
50223 break;
50224 }
50225 color5.R = (byte)((color4.R + color6.R) / 2);
50226 color5.G = (byte)((color4.G + color6.G) / 2);
50227 color5.B = (byte)((color4.B + color6.B) / 2);
50228 color5.R = (byte)((float)(int)color5.R * x);
50229 color5.G = (byte)((float)(int)color5.G * y);
50230 color5.B = (byte)((float)(int)color5.B * z);
50231 spriteBatch.Draw(TextureAssets.Background[array[1]].Value, new Vector2(bgStartX + num6 * num19 + 16 * num21 + num27 + num18, bgStartY + backgroundHeight[array[1]] * num20 + 16 * num22 + num28) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num21 + num27 + num18 + 16, 16 * num22 + num28, width, height), color5);
50232 if (ugBackTransition > 0f)
50233 {
50235 color7.R = (byte)((float)(int)color7.R * ugBackTransition);
50236 color7.G = (byte)((float)(int)color7.G * ugBackTransition);
50237 color7.B = (byte)((float)(int)color7.B * ugBackTransition);
50238 color7.A = (byte)((float)(int)color7.A * ugBackTransition);
50239 spriteBatch.Draw(TextureAssets.Background[array2[1]].Value, new Vector2(bgStartX + num6 * num19 + 16 * num21 + num27 + num18, bgStartY + backgroundHeight[array2[1]] * num20 + 16 * num22 + num28) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num21 + num27 + num18 + 16, 16 * num22 + num28, width, height), color7);
50240 }
50241 }
50242 }
50243 catch
50244 {
50245 color4.R = (byte)((float)(int)color4.R * x);
50246 color4.G = (byte)((float)(int)color4.G * y);
50247 color4.B = (byte)((float)(int)color4.B * z);
50248 spriteBatch.Draw(TextureAssets.Background[array[1]].Value, new Vector2(bgStartX + num6 * num19 + 16 * num21 + num18, bgStartY + backgroundHeight[array[1]] * num20 + 16 * num22) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num21 + num18 + 16, 16 * num22, 16, 16), color4);
50249 }
50250 }
50251 else if ((color4.R > num5 || (double)(int)color4.G > (double)num5 * 1.1 || (double)(int)color4.B > (double)num5 * 1.2) && ugBackTransition == 0f)
50252 {
50253 Lighting.GetColor4Slice(num24, num25, ref slices);
50254 for (int num29 = 0; num29 < 4; num29++)
50255 {
50256 int num30 = 0;
50257 int num31 = 0;
50260 switch (num29)
50261 {
50262 case 1:
50263 num30 = 8;
50264 break;
50265 case 2:
50266 num31 = 8;
50267 break;
50268 case 3:
50269 num30 = 8;
50270 num31 = 8;
50271 break;
50272 }
50273 color8.R = (byte)((color4.R + color9.R) / 2);
50274 color8.G = (byte)((color4.G + color9.G) / 2);
50275 color8.B = (byte)((color4.B + color9.B) / 2);
50276 color8.R = (byte)((float)(int)color8.R * x);
50277 color8.G = (byte)((float)(int)color8.G * y);
50278 color8.B = (byte)((float)(int)color8.B * z);
50279 spriteBatch.Draw(TextureAssets.Background[array[1]].Value, new Vector2(bgStartX + num6 * num19 + 16 * num21 + num30 + num18, bgStartY + backgroundHeight[array[1]] * num20 + 16 * num22 + num31) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num21 + num30 + num18 + 16, 16 * num22 + num31, 8, 8), color8);
50280 if (ugBackTransition > 0f)
50281 {
50283 color10.R = (byte)((float)(int)color10.R * ugBackTransition);
50284 color10.G = (byte)((float)(int)color10.G * ugBackTransition);
50285 color10.B = (byte)((float)(int)color10.B * ugBackTransition);
50286 color10.A = (byte)((float)(int)color10.A * ugBackTransition);
50288 }
50289 }
50290 }
50291 else
50292 {
50293 color4.R = (byte)((float)(int)color4.R * x);
50294 color4.G = (byte)((float)(int)color4.G * y);
50295 color4.B = (byte)((float)(int)color4.B * z);
50296 spriteBatch.Draw(TextureAssets.Background[array[1]].Value, new Vector2(bgStartX + num6 * num19 + 16 * num21 + num18, bgStartY + backgroundHeight[array[1]] * num20 + 16 * num22) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num21 + num18 + 16, 16 * num22, 16, 16), color4);
50297 if (ugBackTransition > 0f)
50298 {
50300 color11.R = (byte)((float)(int)color11.R * ugBackTransition);
50301 color11.G = (byte)((float)(int)color11.G * ugBackTransition);
50302 color11.B = (byte)((float)(int)color11.B * ugBackTransition);
50303 color11.A = (byte)((float)(int)color11.A * ugBackTransition);
50304 spriteBatch.Draw(TextureAssets.Background[array2[1]].Value, new Vector2(bgStartX + num6 * num19 + 16 * num21 + num18, bgStartY + backgroundHeight[array2[1]] * num20 + 16 * num22) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num21 + num18 + 16, 16 * num22, 16, 16), color11);
50305 }
50306 }
50307 }
50308 else
50309 {
50310 color4.R = (byte)((float)(int)color4.R * x);
50311 color4.G = (byte)((float)(int)color4.G * y);
50312 color4.B = (byte)((float)(int)color4.B * z);
50313 if (num > 0f)
50314 {
50315 color4 *= 1f - num;
50316 }
50317 spriteBatch.Draw(TextureAssets.Background[array[1]].Value, new Vector2(bgStartX + num6 * num19 + 16 * num21 + num18, bgStartY + backgroundHeight[array[1]] * num20 + 16 * num22) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num21 + num18 + 16, 16 * num22, 16, 16), color4);
50318 }
50319 }
50320 }
50321 }
50322 }
50323 if (ugBackTransition > 0f)
50324 {
50325 num6 = TextureAssets.Background[array2[1]].Width() - 32;
50326 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50327 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50328 num18 = (int)(float)Math.Round(0f - (float)Math.IEEERemainder((float)bgStartX + screenPosition.X, 16.0));
50329 if (num18 == -8)
50330 {
50331 num18 = 8;
50332 }
50333 for (int num32 = 0; num32 < bgLoops; num32++)
50334 {
50335 for (int num33 = 0; num33 < bgLoopsY; num33++)
50336 {
50337 for (int num34 = 0; num34 < num6 / 16; num34++)
50338 {
50339 for (int num35 = 0; num35 < 6; num35++)
50340 {
50341 float num36 = bgStartY + num33 * 96 + num35 * 16 + 8;
50342 int num37 = (int)(((float)(bgStartX + num6 * num32 + num34 * 16 + 8) + screenPosition.X) / 16f);
50343 int num38 = (int)((num36 + screenPosition.Y) / 16f);
50344 if (WorldGen.InWorld(num37, num38))
50345 {
50346 Microsoft.Xna.Framework.Color color12 = Lighting.GetColor(num37, num38);
50347 if (tile[num37, num38] == null)
50348 {
50349 tile[num37, num38] = new Tile();
50350 }
50351 if (color12.R > 0 || color12.G > 0 || color12.B > 0)
50352 {
50353 Lighting.GetCornerColors(num37, num38, out var vertices2, ugBackTransition);
50354 byte a = (byte)(255f * ugBackTransition);
50355 vertices2.BottomLeftColor.A = a;
50356 vertices2.BottomRightColor.A = a;
50357 vertices2.TopLeftColor.A = a;
50358 vertices2.TopRightColor.A = a;
50360 }
50361 }
50362 }
50363 }
50364 }
50365 }
50366 }
50367 num6 = 128;
50368 if (flag2)
50369 {
50371 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50372 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50374 if (bgTopY > -32)
50375 {
50376 for (int num39 = 0; num39 < bgLoops; num39++)
50377 {
50378 for (int num40 = 0; num40 < num6 / 16; num40++)
50379 {
50380 float num41 = bgStartX + num6 * num39 + num40 * 16 + 8;
50381 float num42 = bgTopY;
50382 Microsoft.Xna.Framework.Color color13 = Lighting.GetColor((int)((num41 + screenPosition.X) / 16f), (int)((screenPosition.Y + num42) / 16f));
50383 color13.R = (byte)((float)(int)color13.R * x);
50384 color13.G = (byte)((float)(int)color13.G * y);
50385 color13.B = (byte)((float)(int)color13.B * z);
50386 if (num > 0f)
50387 {
50388 color13 *= 1f - num;
50389 }
50390 spriteBatch.Draw(TextureAssets.Background[array[2]].Value, new Vector2(bgStartX + num6 * num39 + 16 * num40 + num18, bgTopY) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num40 + num18 + 16, 0, 16, 16), color13);
50391 if (ugBackTransition > 0f)
50392 {
50394 color14.R = (byte)((float)(int)color14.R * ugBackTransition);
50395 color14.G = (byte)((float)(int)color14.G * ugBackTransition);
50396 color14.B = (byte)((float)(int)color14.B * ugBackTransition);
50397 color14.A = (byte)((float)(int)color14.A * ugBackTransition);
50398 spriteBatch.Draw(TextureAssets.Background[array2[2]].Value, new Vector2(bgStartX + num6 * num39 + 16 * num40 + num18, bgTopY) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num40 + num18 + 16, 0, 16, 16), color14);
50399 }
50400 }
50401 }
50402 }
50403 }
50404 }
50405 if (num2 * 16.0 <= (double)(screenPosition.Y + (float)screenHeight) && (!remixWorld || maxTilesX >= 5000))
50406 {
50407 int y2 = 0;
50408 int x2 = 0;
50409 int num43 = screenHeight + 200;
50410 int width2 = screenWidth + 100;
50411 if ((float)UnderworldLayer * 16f < screenPosition.Y + (float)screenHeight)
50412 {
50413 int num44 = (int)(hellBlackBoxBottom - screenPosition.Y + vector.Y);
50414 if (num43 > num44)
50415 {
50416 num43 = num44;
50417 }
50418 }
50420 }
50421 hellBlackBoxBottom = screenPosition.Y + (float)screenHeight + 100f;
50422 bgTopY = (int)((float)((int)rockLayer * 16) - screenPosition.Y + 16f + 600f - 8f);
50423 if (rockLayer * 16.0 <= (double)(screenPosition.Y + (float)screenHeight))
50424 {
50426 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50427 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50428 if (rockLayer * 16.0 + (double)screenHeight < (double)(screenPosition.Y - 16f))
50429 {
50431 bgLoopsY = (screenHeight - bgStartY + (int)vector.Y * 2) / backgroundHeight[2] + 1;
50432 }
50433 else
50434 {
50435 bgStartY = bgTopY;
50436 bgLoopsY = (screenHeight - bgTopY + (int)vector.Y * 2) / backgroundHeight[2] + 1;
50437 }
50438 if (num2 * 16.0 < (double)(screenPosition.Y + (float)screenHeight))
50439 {
50440 bgLoopsY = (int)(num2 * 16.0 - (double)screenPosition.Y + 600.0 - (double)bgStartY) / backgroundHeight[2];
50441 flag = true;
50442 }
50443 int num45 = (int)(float)Math.Round(0f - (float)Math.IEEERemainder((float)bgStartX + screenPosition.X, 16.0));
50444 if (num45 == -8)
50445 {
50446 num45 = 8;
50447 }
50448 for (int num46 = 0; num46 < bgLoops; num46++)
50449 {
50450 for (int num47 = 0; num47 < bgLoopsY; num47++)
50451 {
50452 for (int num48 = 0; num48 < num6 / 16; num48++)
50453 {
50454 for (int num49 = 0; num49 < 6; num49++)
50455 {
50456 float num50 = bgStartY + num47 * 96 + num49 * 16 + 8;
50457 int num51 = (int)(((float)(bgStartX + num6 * num46 + num48 * 16 + 8) + screenPosition.X) / 16f);
50458 int num52 = (int)((num50 + screenPosition.Y) / 16f);
50459 if (!WorldGen.InWorld(num51, num52, 1))
50460 {
50461 continue;
50462 }
50463 Microsoft.Xna.Framework.Color color15 = Lighting.GetColor(num51, num52);
50464 if ((!ShouldDrawBackgroundTileAt(num51, num52) && color15.R != 0 && color15.G != 0 && color15.B != 0) || (color15.R <= 0 && color15.G <= 0 && color15.B <= 0) || (!WallLightAt(num51, num52) && caveParallax == 0f))
50465 {
50466 continue;
50467 }
50468 if (num == 0f && Lighting.NotRetro && color15.R < 230 && color15.G < 230 && color15.B < 230 && ugBackTransition == 0f)
50469 {
50470 if ((color15.R > num4 || (double)(int)color15.G > (double)num4 * 1.1 || (double)(int)color15.B > (double)num4 * 1.2) && !tile[num51, num52].active())
50471 {
50472 Lighting.GetColor9Slice(num51, num52, ref slices);
50473 for (int num53 = 0; num53 < 9; num53++)
50474 {
50475 int num54 = 0;
50476 int num55 = 0;
50477 int width3 = 4;
50478 int height2 = 4;
50481 switch (num53)
50482 {
50483 case 0:
50484 if (!tile[num51 - 1, num52 - 1].active())
50485 {
50486 color17 = slices[num53];
50487 }
50488 break;
50489 case 1:
50490 width3 = 8;
50491 num54 = 4;
50492 if (!tile[num51, num52 - 1].active())
50493 {
50494 color17 = slices[num53];
50495 }
50496 break;
50497 case 2:
50498 num54 = 12;
50499 if (!tile[num51 + 1, num52 - 1].active())
50500 {
50501 color17 = slices[num53];
50502 }
50503 break;
50504 case 3:
50505 height2 = 8;
50506 num55 = 4;
50507 if (!tile[num51 - 1, num52].active())
50508 {
50509 color17 = slices[num53];
50510 }
50511 break;
50512 case 4:
50513 width3 = 8;
50514 height2 = 8;
50515 num54 = 4;
50516 num55 = 4;
50517 break;
50518 case 5:
50519 num54 = 12;
50520 num55 = 4;
50521 height2 = 8;
50522 if (!tile[num51 + 1, num52].active())
50523 {
50524 color17 = slices[num53];
50525 }
50526 break;
50527 case 6:
50528 num55 = 12;
50529 if (!tile[num51 - 1, num52 + 1].active())
50530 {
50531 color17 = slices[num53];
50532 }
50533 break;
50534 case 7:
50535 width3 = 8;
50536 height2 = 4;
50537 num54 = 4;
50538 num55 = 12;
50539 if (!tile[num51, num52 + 1].active())
50540 {
50541 color17 = slices[num53];
50542 }
50543 break;
50544 case 8:
50545 num54 = 12;
50546 num55 = 12;
50547 if (!tile[num51 + 1, num52 + 1].active())
50548 {
50549 color17 = slices[num53];
50550 }
50551 break;
50552 }
50553 color16.R = (byte)((color15.R + color17.R) / 2);
50554 color16.G = (byte)((color15.G + color17.G) / 2);
50555 color16.B = (byte)((color15.B + color17.B) / 2);
50556 color16.R = (byte)((float)(int)color16.R * x);
50557 color16.G = (byte)((float)(int)color16.G * y);
50558 color16.B = (byte)((float)(int)color16.B * z);
50560 if (ugBackTransition > 0f)
50561 {
50563 color18.R = (byte)((float)(int)color18.R * ugBackTransition);
50564 color18.G = (byte)((float)(int)color18.G * ugBackTransition);
50565 color18.B = (byte)((float)(int)color18.B * ugBackTransition);
50566 color18.A = (byte)((float)(int)color18.A * ugBackTransition);
50568 }
50569 }
50570 }
50571 else if (color15.R > num5 || (double)(int)color15.G > (double)num5 * 1.1 || (double)(int)color15.B > (double)num5 * 1.2)
50572 {
50573 Lighting.GetColor4Slice(num51, num52, ref slices);
50574 for (int num56 = 0; num56 < 4; num56++)
50575 {
50576 int num57 = 0;
50577 int num58 = 0;
50580 switch (num56)
50581 {
50582 case 1:
50583 num57 = 8;
50584 break;
50585 case 2:
50586 num58 = 8;
50587 break;
50588 case 3:
50589 num57 = 8;
50590 num58 = 8;
50591 break;
50592 }
50593 color19.R = (byte)((color15.R + color20.R) / 2);
50594 color19.G = (byte)((color15.G + color20.G) / 2);
50595 color19.B = (byte)((color15.B + color20.B) / 2);
50596 color19.R = (byte)((float)(int)color19.R * x);
50597 color19.G = (byte)((float)(int)color19.G * y);
50598 color19.B = (byte)((float)(int)color19.B * z);
50600 if (ugBackTransition > 0f)
50601 {
50603 color21.R = (byte)((float)(int)color21.R * ugBackTransition);
50604 color21.G = (byte)((float)(int)color21.G * ugBackTransition);
50605 color21.B = (byte)((float)(int)color21.B * ugBackTransition);
50606 color21.A = (byte)((float)(int)color21.A * ugBackTransition);
50608 }
50609 }
50610 }
50611 else
50612 {
50613 color15.R = (byte)((float)(int)color15.R * x);
50614 color15.G = (byte)((float)(int)color15.G * y);
50615 color15.B = (byte)((float)(int)color15.B * z);
50616 spriteBatch.Draw(TextureAssets.Background[array[3]].Value, new Vector2(bgStartX + num6 * num46 + 16 * num48 + num45, bgStartY + backgroundHeight[array[3]] * num47 + 16 * num49) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num48 + num45 + 16, 16 * num49, 16, 16), color15);
50617 if (ugBackTransition > 0f)
50618 {
50620 color22.R = (byte)((float)(int)color22.R * ugBackTransition);
50621 color22.G = (byte)((float)(int)color22.G * ugBackTransition);
50622 color22.B = (byte)((float)(int)color22.B * ugBackTransition);
50623 color22.A = (byte)((float)(int)color22.A * ugBackTransition);
50624 spriteBatch.Draw(TextureAssets.Background[array2[3]].Value, new Vector2(bgStartX + num6 * num46 + 16 * num48 + num45, bgStartY + backgroundHeight[array2[3]] * num47 + 16 * num49) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num48 + num45 + 16, 16 * num49, 16, 16), color22);
50625 }
50626 }
50627 }
50628 else
50629 {
50630 color15.R = (byte)((float)(int)color15.R * x);
50631 color15.G = (byte)((float)(int)color15.G * y);
50632 color15.B = (byte)((float)(int)color15.B * z);
50633 if (num > 0f)
50634 {
50635 color15 *= 1f - num;
50636 }
50637 spriteBatch.Draw(TextureAssets.Background[array[3]].Value, new Vector2(bgStartX + num6 * num46 + 16 * num48 + num45, bgStartY + backgroundHeight[array[3]] * num47 + 16 * num49) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num48 + num45 + 16, 16 * num49, 16, 16), color15);
50638 if (ugBackTransition > 0f)
50639 {
50641 color23.R = (byte)((float)(int)color23.R * ugBackTransition);
50642 color23.G = (byte)((float)(int)color23.G * ugBackTransition);
50643 color23.B = (byte)((float)(int)color23.B * ugBackTransition);
50644 color23.A = (byte)((float)(int)color23.A * ugBackTransition);
50645 spriteBatch.Draw(TextureAssets.Background[array2[3]].Value, new Vector2(bgStartX + num6 * num46 + 16 * num48 + num45, bgStartY + backgroundHeight[array2[3]] * num47 + 16 * num49) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num48 + num45 + 16, 16 * num49, 16, 16), color23);
50646 }
50647 }
50648 }
50649 }
50650 }
50651 }
50652 num6 = 128;
50653 if (flag)
50654 {
50656 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50657 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50659 for (int num59 = 0; num59 < bgLoops; num59++)
50660 {
50661 for (int num60 = 0; num60 < num6 / 16; num60++)
50662 {
50663 float num61 = bgStartX + num6 * num59 + num60 * 16 + 8;
50664 float num62 = bgTopY;
50665 Microsoft.Xna.Framework.Color color24 = Lighting.GetColor((int)((num61 + screenPosition.X) / 16f), (int)((screenPosition.Y + num62) / 16f));
50666 color24.R = (byte)((float)(int)color24.R * x);
50667 color24.G = (byte)((float)(int)color24.G * y);
50668 color24.B = (byte)((float)(int)color24.B * z);
50669 spriteBatch.Draw(TextureAssets.Background[array[4]].Value, new Vector2(bgStartX + num6 * num59 + 16 * num60 + num45, bgTopY) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num60 + num45 + 16, magmaBGFrame * 16, 16, 16), color24);
50670 if (ugBackTransition > 0f)
50671 {
50673 color25.R = (byte)((float)(int)color25.R * ugBackTransition);
50674 color25.G = (byte)((float)(int)color25.G * ugBackTransition);
50675 color25.B = (byte)((float)(int)color25.B * ugBackTransition);
50676 color25.A = (byte)((float)(int)color25.A * ugBackTransition);
50677 spriteBatch.Draw(TextureAssets.Background[array2[4]].Value, new Vector2(bgStartX + num6 * num59 + 16 * num60 + num45, bgTopY) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num60 + num45 + 16, magmaBGFrame * 16, 16, 16), color25);
50678 }
50679 }
50680 }
50681 }
50682 }
50683 bgTopY = (int)((float)((int)num2 * 16) - screenPosition.Y + 16f + 600f) - 8;
50684 bool flag3 = false;
50685 if (num2 * 16.0 <= (double)(screenPosition.Y + (float)screenHeight))
50686 {
50687 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50688 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50689 if (num2 * 16.0 + (double)screenHeight < (double)(screenPosition.Y - 16f))
50690 {
50692 bgLoopsY = (screenHeight - bgStartY + (int)vector.Y * 2) / backgroundHeight[2] + 1;
50693 }
50694 else
50695 {
50696 bgStartY = bgTopY;
50697 bgLoopsY = (screenHeight - bgTopY + (int)vector.Y * 2) / backgroundHeight[2] + 1;
50698 }
50699 if ((float)UnderworldLayer * 16f < screenPosition.Y + (float)screenHeight)
50700 {
50701 bgLoopsY = (int)Math.Ceiling(((float)UnderworldLayer * 16f - screenPosition.Y - (float)bgStartY) / (float)backgroundHeight[2]);
50702 flag3 = true;
50703 }
50704 num4 = (int)((double)num4 * 1.5);
50705 num5 = (int)((double)num5 * 1.5);
50706 int num63 = (int)(float)Math.Round(0f - (float)Math.IEEERemainder((float)bgStartX + screenPosition.X, 16.0));
50707 if (num63 == -8)
50708 {
50709 num63 = 8;
50710 }
50711 for (int num64 = 0; num64 < bgLoops; num64++)
50712 {
50713 for (int num65 = 0; num65 < bgLoopsY; num65++)
50714 {
50715 for (int num66 = 0; num66 < num6 / 16; num66++)
50716 {
50717 for (int num67 = 0; num67 < 6; num67++)
50718 {
50719 float num68 = bgStartY + num65 * 96 + num67 * 16 + 8;
50720 int num69 = (int)(((float)(bgStartX + num6 * num64 + num66 * 16 + 8) + screenPosition.X) / 16f);
50721 int num70 = (int)((num68 + screenPosition.Y) / 16f);
50722 if (!WorldGen.InWorld(num69, num70, 1))
50723 {
50724 continue;
50725 }
50726 Microsoft.Xna.Framework.Color color26 = Lighting.GetColor(num69, num70);
50727 if ((!ShouldDrawBackgroundTileAt(num69, num70) && color26.R != 0 && color26.G != 0 && color26.B != 0) || (color26.R <= 0 && color26.G <= 0 && color26.B <= 0 && num70 <= maxTilesY - 300) || (!WallLightAt(num69, num70) && caveParallax == 0f))
50728 {
50729 continue;
50730 }
50731 if (Lighting.NotRetro && color26.R < 230 && color26.G < 230 && color26.B < 230)
50732 {
50733 if ((color26.R > num4 || (double)(int)color26.G > (double)num4 * 1.1 || (double)(int)color26.B > (double)num4 * 1.2) && !tile[num69, num70].active())
50734 {
50735 Lighting.GetColor9Slice(num69, num70, ref slices);
50736 for (int num71 = 0; num71 < 9; num71++)
50737 {
50738 int num72 = 0;
50739 int num73 = 0;
50740 int width4 = 4;
50741 int height3 = 4;
50744 switch (num71)
50745 {
50746 case 0:
50747 if (!tile[num69 - 1, num70 - 1].active())
50748 {
50749 color28 = slices[num71];
50750 }
50751 break;
50752 case 1:
50753 width4 = 8;
50754 num72 = 4;
50755 if (!tile[num69, num70 - 1].active())
50756 {
50757 color28 = slices[num71];
50758 }
50759 break;
50760 case 2:
50761 num72 = 12;
50762 if (!tile[num69 + 1, num70 - 1].active())
50763 {
50764 color28 = slices[num71];
50765 }
50766 break;
50767 case 3:
50768 height3 = 8;
50769 num73 = 4;
50770 if (!tile[num69 - 1, num70].active())
50771 {
50772 color28 = slices[num71];
50773 }
50774 break;
50775 case 4:
50776 width4 = 8;
50777 height3 = 8;
50778 num72 = 4;
50779 num73 = 4;
50780 break;
50781 case 5:
50782 num72 = 12;
50783 num73 = 4;
50784 height3 = 8;
50785 if (!tile[num69 + 1, num70].active())
50786 {
50787 color28 = slices[num71];
50788 }
50789 break;
50790 case 6:
50791 num73 = 12;
50792 if (!tile[num69 - 1, num70 + 1].active())
50793 {
50794 color28 = slices[num71];
50795 }
50796 break;
50797 case 7:
50798 width4 = 8;
50799 height3 = 4;
50800 num72 = 4;
50801 num73 = 12;
50802 if (!tile[num69, num70 + 1].active())
50803 {
50804 color28 = slices[num71];
50805 }
50806 break;
50807 case 8:
50808 num72 = 12;
50809 num73 = 12;
50810 if (!tile[num69 + 1, num70 + 1].active())
50811 {
50812 color28 = slices[num71];
50813 }
50814 break;
50815 }
50816 color27.R = (byte)((color26.R + color28.R) / 2);
50817 color27.G = (byte)((color26.G + color28.G) / 2);
50818 color27.B = (byte)((color26.B + color28.B) / 2);
50819 color27.R = (byte)((float)(int)color27.R * x);
50820 color27.G = (byte)((float)(int)color27.G * y);
50821 color27.B = (byte)((float)(int)color27.B * z);
50823 }
50824 }
50825 else if (color26.R > num5 || (double)(int)color26.G > (double)num5 * 1.1 || (double)(int)color26.B > (double)num5 * 1.2)
50826 {
50827 Lighting.GetColor4Slice(num69, num70, ref slices);
50828 for (int num74 = 0; num74 < 4; num74++)
50829 {
50830 int num75 = 0;
50831 int num76 = 0;
50834 switch (num74)
50835 {
50836 case 1:
50837 num75 = 8;
50838 break;
50839 case 2:
50840 num76 = 8;
50841 break;
50842 case 3:
50843 num75 = 8;
50844 num76 = 8;
50845 break;
50846 }
50847 color29.R = (byte)((color26.R + color30.R) / 2);
50848 color29.G = (byte)((color26.G + color30.G) / 2);
50849 color29.B = (byte)((color26.B + color30.B) / 2);
50850 color29.R = (byte)((float)(int)color29.R * x);
50851 color29.G = (byte)((float)(int)color29.G * y);
50852 color29.B = (byte)((float)(int)color29.B * z);
50853 spriteBatch.Draw(TextureAssets.Background[array[5]].Value, new Vector2(bgStartX + num6 * num64 + 16 * num66 + num75 + num63, bgStartY + backgroundHeight[2] * num65 + 16 * num67 + num76) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num66 + num75 + num63 + 16, 16 * num67 + backgroundHeight[2] * magmaBGFrame + num76, 8, 8), color29, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
50854 }
50855 }
50856 else
50857 {
50858 color26.R = (byte)((float)(int)color26.R * x);
50859 color26.G = (byte)((float)(int)color26.G * y);
50860 color26.B = (byte)((float)(int)color26.B * z);
50861 spriteBatch.Draw(TextureAssets.Background[array[5]].Value, new Vector2(bgStartX + num6 * num64 + 16 * num66 + num63, bgStartY + backgroundHeight[2] * num65 + 16 * num67) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num66 + num63 + 16, 16 * num67 + backgroundHeight[2] * magmaBGFrame, 16, 16), color26, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
50862 }
50863 }
50864 else
50865 {
50866 color26.R = (byte)((float)(int)color26.R * x);
50867 color26.G = (byte)((float)(int)color26.G * y);
50868 color26.B = (byte)((float)(int)color26.B * z);
50869 spriteBatch.Draw(TextureAssets.Background[array[5]].Value, new Vector2(bgStartX + num6 * num64 + 16 * num66 + num63, bgStartY + backgroundHeight[2] * num65 + 16 * num67) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num66 + num63 + 16, 16 * num67 + backgroundHeight[2] * magmaBGFrame, 16, 16), color26, 0f, default(Vector2), 1f, SpriteEffects.None, 0f);
50870 }
50871 }
50872 }
50873 }
50874 }
50875 if (flag3)
50876 {
50878 bgStartX = (int)(0.0 - Math.IEEERemainder((double)num6 + (double)screenPosition.X * bgParallax, num6) - (double)(num6 / 2)) - (int)vector.X;
50879 bgLoops = (screenWidth + (int)vector.X * 2) / num6 + 2;
50882 for (int num77 = 0; num77 < bgLoops; num77++)
50883 {
50884 for (int num78 = 0; num78 < num6 / 16; num78++)
50885 {
50886 float num79 = bgStartX + num6 * num77 + num78 * 16 + 8;
50887 float num80 = bgTopY;
50888 Microsoft.Xna.Framework.Color color31 = Lighting.GetColor((int)((num79 + screenPosition.X) / 16f), (int)((screenPosition.Y + num80) / 16f));
50889 color31.R = (byte)((float)(int)color31.R * x);
50890 color31.G = (byte)((float)(int)color31.G * y);
50891 color31.B = (byte)((float)(int)color31.B * z);
50892 spriteBatch.Draw(TextureAssets.Background[array[6]].Value, new Vector2(bgStartX + num6 * num77 + 16 * num78 + num63, bgTopY) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num78 + num63 + 16, magmaBGFrame * 16, 16, 16), color31);
50893 if (ugBackTransition > 0f)
50894 {
50896 color32.R = (byte)((float)(int)color32.R * ugBackTransition);
50897 color32.G = (byte)((float)(int)color32.G * ugBackTransition);
50898 color32.B = (byte)((float)(int)color32.B * ugBackTransition);
50899 color32.A = (byte)((float)(int)color32.A * ugBackTransition);
50900 spriteBatch.Draw(TextureAssets.Background[array2[6]].Value, new Vector2(bgStartX + num6 * num77 + 16 * num78 + num63, bgTopY) + vector, new Microsoft.Xna.Framework.Rectangle(16 * num78 + num63 + 16, magmaBGFrame * 16, 16, 16), color32);
50901 }
50902 }
50903 }
50904 }
50905 }
50906 Lighting.GlobalBrightness = globalBrightness;
50907 TimeLogger.DrawTime(3, stopwatch.Elapsed.TotalMilliseconds);
50908 }
static float Clamp(float value, float min, float max)
Definition MathHelper.cs:46
static decimal Round(decimal d)
Definition Math.cs:1096
static double Ceiling(double a)
static double IEEERemainder(double x, double y)
Definition Math.cs:679
static Asset< Texture2D >[] Background
static Asset< Texture2D > BlackTile
static SceneMetrics SceneMetrics
Definition Main.cs:1344
double bgParallax
Definition Main.cs:956
static int maxTilesY
Definition Main.cs:1116
void LoadBackground(int i)
Definition Main.cs:55998
static SpriteBatch spriteBatch
Definition Main.cs:974
static double worldSurface
Definition Main.cs:1272
static int myPlayer
Definition Main.cs:1801
static float gfxQuality
Definition Main.cs:1056
static bool WallLightAt(int i, int j)
Definition Main.cs:51985
static double rockLayer
Definition Main.cs:1274
static bool drawToScreen
Definition Main.cs:600
static int magmaBGFrame
Definition Main.cs:1096
static int oldUndergroundBackground
Definition Main.cs:558
int bgTopY
Definition Main.cs:966
static int[] caveBackStyle
Definition Main.cs:674
static float ugBackTransition
Definition Main.cs:1268
void OldDrawBackground()
Definition Main.cs:50915
static int screenHeight
Definition Main.cs:1721
static Vector2 screenPosition
Definition Main.cs:1715
static bool BackgroundEnabled
Definition Main.cs:802
static int undergroundBackground
Definition Main.cs:556
static int maxTilesX
Definition Main.cs:1114
static int offScreenRange
Definition Main.cs:836
int bgLoops
Definition Main.cs:960
static Tile[,] tile
Definition Main.cs:1675
static int hellBackStyle
Definition Main.cs:678
int bgLoopsY
Definition Main.cs:964
static TileBatch tileBatch
Definition Main.cs:976
static int jungleBackStyle
Definition Main.cs:680
int bgStartX
Definition Main.cs:958
int bgStartY
Definition Main.cs:962
static int[] backgroundHeight
Definition Main.cs:1667
static int worldID
Definition Main.cs:1262
static float caveParallax
Definition Main.cs:1216
static int screenWidth
Definition Main.cs:1719
static int UnderworldLayer
Definition Main.cs:2825
static int iceBackStyle
Definition Main.cs:676
static bool ShouldDrawBackgroundTileAt(int i, int j)
Definition Main.cs:51957
float hellBlackBoxBottom
Definition Main.cs:2539
static int[] caveBackX
Definition Main.cs:672
static float shimmerAlpha
Definition Main.cs:1008
static Player[] player
Definition Main.cs:1803
static bool remixWorld
Definition Main.cs:349

References System.array, Microsoft.Xna.Framework.Color.B, Terraria.GameContent.TextureAssets.Background, Terraria.Main.BackgroundEnabled, Terraria.Main.backgroundHeight, Terraria.Main.bgLoops, Terraria.Main.bgLoopsY, Terraria.Main.bgParallax, Terraria.Main.bgStartX, Terraria.Main.bgStartY, Terraria.Main.bgTopY, Terraria.GameContent.TextureAssets.BlackTile, Terraria.Main.caveBackStyle, Terraria.Main.caveBackX, Terraria.Main.caveParallax, System.Math.Ceiling(), Microsoft.Xna.Framework.MathHelper.Clamp(), Terraria.TimeLogger.DrawTime(), Terraria.Main.drawToScreen, Microsoft.Xna.Framework.Color.G, Terraria.Lighting.GetColor(), Terraria.Lighting.GetColor4Slice(), Terraria.Lighting.GetColor9Slice(), Terraria.Lighting.GetCornerColors(), Terraria.Main.gfxQuality, Terraria.Lighting.GlobalBrightness, Terraria.Main.hellBackStyle, Terraria.Main.hellBlackBoxBottom, System.Text.RegularExpressions.i, Terraria.Main.iceBackStyle, System.Math.IEEERemainder(), Terraria.WorldGen.InWorld(), Terraria.Main.jungleBackStyle, Terraria.SceneMetrics.JungleTileCount, Terraria.SceneMetrics.JungleTileThreshold, Terraria.Main.LoadBackground(), Terraria.Main.magmaBGFrame, Terraria.Main.maxTilesX, Terraria.Main.maxTilesY, Terraria.Main.myPlayer, Terraria.Lighting.NotRetro, Terraria.WorldGen.oceanDepths(), Terraria.Main.offScreenRange, Terraria.Main.OldDrawBackground(), Terraria.Main.oldUndergroundBackground, Terraria.Main.player, Microsoft.Xna.Framework.Color.R, Terraria.Main.remixWorld, Terraria.Main.rockLayer, System.Math.Round(), Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, Terraria.Main.shimmerAlpha, Terraria.Main.ShouldDrawBackgroundTileAt(), Terraria.SceneMetrics.SnowTileCount, Terraria.SceneMetrics.SnowTileThreshold, Terraria.Main.spriteBatch, Terraria.DataStructures.Tile, Terraria.Main.tile, Terraria.Main.tileBatch, Terraria.Main.ugBackTransition, Terraria.Main.undergroundBackground, Terraria.Main.UnderworldLayer, System.value, Microsoft.Xna.Framework.Graphics.Vector2, Microsoft.Xna.Framework.Graphics.Vector3, Terraria.Main.WallLightAt(), Terraria.Main.worldID, Terraria.Main.worldSurface, and Microsoft.Xna.Framework.Vector2.Zero.

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