181 {
182 if (!GlobalBgStyleLoader.loaded) {
183 return;
184 }
185 if (Main.bgAlpha[style] <= 0f) {
186 return;
187 }
189 if (surfaceBgStyle != null && surfaceBgStyle.PreDrawCloseBackground(Main.spriteBatch)) {
190 Main.bgScale = 1.25f;
191 Main.instance.bgParallax = 0.37;
192 float a = 1800.0f;
193 float b = 1750.0f;
194 int textureSlot = surfaceBgStyle.ChooseCloseTexture(ref Main.bgScale, ref Main.instance.bgParallax, ref a, ref b);
195 if (textureSlot >= 0 && textureSlot < Main.backgroundTexture.Length) {
196
197 Main.instance.LoadBackground(textureSlot);
198 Main.bgScale *= 2f;
199 Main.bgW = (int)((float)Main.backgroundWidth[textureSlot] * Main.bgScale);
200 SkyManager.Instance.DrawToDepth(Main.spriteBatch, 1f / (float)Main.instance.bgParallax);
201 Main.instance.bgStart = (int)(-Math.IEEERemainder(Main.screenPosition.X * Main.instance.bgParallax, Main.bgW) - (Main.bgW / 2));
202 Main.instance.bgTop = (int)((-Main.screenPosition.Y + Main.instance.screenOff / 2f) / (Main.worldSurface * 16.0) * a + b) + (int)Main.instance.scAdj;
203 if (Main.gameMenu) {
204 Main.instance.bgTop = 320;
205 }
206 Main.instance.bgLoops = Main.screenWidth / Main.bgW + 2;
207 if ((double)Main.screenPosition.Y < Main.worldSurface * 16.0 + 16.0) {
208 for (int k = 0; k < Main.instance.bgLoops; k++) {
209 Main.spriteBatch.Draw(Main.backgroundTexture[textureSlot],
210 new Vector2((Main.instance.bgStart + Main.bgW * k), Main.instance.bgTop),
211 new Rectangle(0, 0, Main.backgroundWidth[textureSlot], Main.backgroundHeight[textureSlot]),
212 Main.backColor, 0f, default(Vector2), Main.bgScale, SpriteEffects.None, 0f);
213 }
214 }
215 }
216 }
217 }
static ModSurfaceBgStyle GetSurfaceBgStyle(int style)
Returns the ModSurfaceBgStyle object with the given ID.