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

◆ DrawUnderworldBackgroudLayer()

static void Terraria.Main.DrawUnderworldBackgroudLayer ( bool flat,
Vector2 screenOffset,
float pushUp,
int layerTextureIndex )
inlinestaticprivate

Definition at line 49562 of file Main.cs.

49563 {
49566 if (!val.IsLoaded)
49567 {
49568 Assets.Request<Texture2D>(val.Name, (AssetRequestMode)1);
49569 }
49570 Texture2D value = val.Value;
49571 Vector2 vec = new Vector2(value.Width, value.Height) * 0.5f;
49572 float num2 = (flat ? 1f : ((float)(layerTextureIndex * 2) + 3f));
49573 Vector2 vector = new Vector2(1f / num2);
49575 float num3 = 1.3f;
49577 int num4 = 0;
49578 switch (num)
49579 {
49580 case 1:
49581 {
49582 int num9 = (int)(GlobalTimeWrappedHourly * 8f) % 4;
49583 value2 = new Microsoft.Xna.Framework.Rectangle((num9 >> 1) * (value.Width >> 1), num9 % 2 * (value.Height >> 1), value.Width >> 1, value.Height >> 1);
49584 vec *= 0.5f;
49585 zero.Y += 175f;
49586 break;
49587 }
49588 case 2:
49589 zero.Y += 100f;
49590 break;
49591 case 3:
49592 zero.Y += 75f;
49593 break;
49594 case 4:
49595 num3 = 0.5f;
49596 zero.Y -= 0f;
49597 break;
49598 case 5:
49599 zero.Y += num4;
49600 break;
49601 case 6:
49602 {
49603 int num8 = (int)(GlobalTimeWrappedHourly * 8f) % 4;
49604 value2 = new Microsoft.Xna.Framework.Rectangle(num8 % 2 * (value.Width >> 1), (num8 >> 1) * (value.Height >> 1), value.Width >> 1, value.Height >> 1);
49605 vec *= 0.5f;
49606 zero.Y += num4;
49607 zero.Y += -60f;
49608 break;
49609 }
49610 case 7:
49611 {
49612 int num7 = (int)(GlobalTimeWrappedHourly * 8f) % 4;
49613 value2 = new Microsoft.Xna.Framework.Rectangle(num7 % 2 * (value.Width >> 1), (num7 >> 1) * (value.Height >> 1), value.Width >> 1, value.Height >> 1);
49614 vec *= 0.5f;
49615 zero.Y += num4;
49616 zero.X -= 400f;
49617 zero.Y += 90f;
49618 break;
49619 }
49620 case 8:
49621 {
49622 int num6 = (int)(GlobalTimeWrappedHourly * 8f) % 4;
49623 value2 = new Microsoft.Xna.Framework.Rectangle(num6 % 2 * (value.Width >> 1), (num6 >> 1) * (value.Height >> 1), value.Width >> 1, value.Height >> 1);
49624 vec *= 0.5f;
49625 zero.Y += num4;
49626 zero.Y += 90f;
49627 break;
49628 }
49629 case 9:
49630 zero.Y += num4;
49631 zero.Y -= 30f;
49632 break;
49633 case 10:
49634 zero.Y += 250f * num2;
49635 break;
49636 case 11:
49637 zero.Y += 100f * num2;
49638 break;
49639 case 12:
49640 zero.Y += 20f * num2;
49641 break;
49642 case 13:
49643 {
49644 zero.Y += 20f * num2;
49645 int num5 = (int)(GlobalTimeWrappedHourly * 8f) % 4;
49646 value2 = new Microsoft.Xna.Framework.Rectangle(num5 % 2 * (value.Width >> 1), (num5 >> 1) * (value.Height >> 1), value.Width >> 1, value.Height >> 1);
49647 vec *= 0.5f;
49648 break;
49649 }
49650 }
49651 if (flat)
49652 {
49653 num3 *= 1.5f;
49654 }
49655 vec *= num3;
49656 SkyManager.Instance.DrawToDepth(spriteBatch, 1f / vector.X);
49657 if (flat)
49658 {
49659 zero.Y += (float)(TextureAssets.Underworld[0].Height() >> 1) * 1.3f - vec.Y;
49660 }
49661 zero.Y -= pushUp;
49662 float num10 = num3 * (float)value2.Width;
49663 int num11 = (int)((float)(int)(screenOffset.X * vector.X - vec.X + zero.X - (float)(screenWidth >> 1)) / num10);
49664 vec = vec.Floor();
49665 int num12 = (int)Math.Ceiling((float)screenWidth / num10);
49666 int num13 = (int)(num3 * ((float)(value2.Width - 1) / vector.X));
49668 vec2 = vec2.Floor();
49669 while (vec2.X + num10 < 0f)
49670 {
49671 num11++;
49672 vec2.X += num10;
49673 }
49674 for (int i = num11 - 2; i <= num11 + 4 + num12; i++)
49675 {
49677 if (layerTextureIndex == 0)
49678 {
49679 int num14 = (int)(vec2.Y + (float)value2.Height * num3);
49680 spriteBatch.Draw(TextureAssets.BlackTile.Value, new Microsoft.Xna.Framework.Rectangle((int)vec2.X, num14, (int)((float)value2.Width * num3), Math.Max(0, screenHeight - num14)), new Microsoft.Xna.Framework.Color(11, 3, 7));
49681 }
49682 vec2.X += num10;
49683 }
49684 }
static double Ceiling(double a)
static byte Max(byte val1, byte val2)
Definition Math.cs:738
static Asset< Texture2D >[] Underworld
static Asset< Texture2D > BlackTile
static int[] underworldBG
Definition Main.cs:666
static SpriteBatch spriteBatch
Definition Main.cs:974
static int screenHeight
Definition Main.cs:1721
static Vector2 screenPosition
Definition Main.cs:1715
static int screenWidth
Definition Main.cs:1719
static int UnderworldLayer
Definition Main.cs:2825
static IAssetRepository Assets
Definition Main.cs:209
static float GlobalTimeWrappedHourly
Definition Main.cs:405

References Terraria.Main.Assets, Terraria.GameContent.TextureAssets.BlackTile, System.Math.Ceiling(), Terraria.Main.GlobalTimeWrappedHourly, System.Text.RegularExpressions.i, Terraria.Graphics.Effects.SkyManager.Instance, System.Math.Max(), Terraria.Main.screenHeight, Terraria.Main.screenPosition, Terraria.Main.screenWidth, Terraria.Main.spriteBatch, Terraria.GameContent.TextureAssets.Underworld, Terraria.Main.underworldBG, Terraria.Main.UnderworldLayer, System.value, Microsoft.Xna.Framework.Graphics.Vector2, Microsoft.Xna.Framework.Color.White, and Microsoft.Xna.Framework.Vector2.Zero.

Referenced by Terraria.Main.DrawUnderworldBackground().