diff --git a/Backgrounds/SunkenSeaBurrowsBG.cs b/Backgrounds/SunkenSeaBurrowsBG.cs index 838eda9488..3f1369eb74 100644 --- a/Backgrounds/SunkenSeaBurrowsBG.cs +++ b/Backgrounds/SunkenSeaBurrowsBG.cs @@ -73,6 +73,7 @@ namespace CalamityMod.Backgrounds // Leaving this here for other programmers, in case I don't get to doing this myself. Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, Main.Rasterizer, null, CalamityUtils.BackgroundMatrix); + DrawShoresBG(); DrawBurrowsBG(); Main.spriteBatch.End(); @@ -97,6 +98,7 @@ namespace CalamityMod.Backgrounds // rendering code if that setting is on. if (Main.WaveQuality > 0 || !CalamityClientConfig.Instance.SunkenSeaBackgroundDistortion) { + DrawShoresBG(); DrawBurrowsBG(); } else @@ -123,14 +125,103 @@ namespace CalamityMod.Backgrounds } public static float Transparency; - public static float TransitionSpeed => 0.02f; + private static void DrawShoresBG() + { + if (Main.LocalPlayer.InModBiome(ModContent.GetInstance())) + { + Transparency += 1f; + + if (Transparency > 1f) + Transparency = 1f; + } + else + { + // Make transparency immediately go down so it doesnt look weird, since vanilla underground backgrounds dont have the fade-in effect this background has. + Transparency -= 1f; + + if (Transparency < 0f) + Transparency = 0f; + } + + // Don't bother running any of the background drawing if the transparency is zero (meaning the background isnt actually active). + // Also do not run any of the background drawing if you have the vanilla background config option turned off. + if (Transparency > 0f && Main.BackgroundEnabled) + { + Vector2 vector = Main.screenPosition + new Vector2((Main.screenWidth >> 1), (Main.screenHeight >> 1)); + float num = (Main.GameViewMatrix.Zoom.Y - 1f) * 0.5f * 200f; + float Scale = 1.5f; + float playerDrawPosition = ((Main.LocalPlayer.Center.Y / 16f) - 90) * 16f; + + for (int Layers = 4; Layers >= 0; Layers--) + { + // Get each background texture. + Texture2D BGTexture = ModContent.Request("CalamityMod/Backgrounds/SunkenSeaShoresBG" + Layers).Value; + + Vector2 vector2 = new Vector2(BGTexture.Width, BGTexture.Height) * 0.5f; + float num2 = (Layers * 2 + 3f); + Vector2 vector3 = new Vector2(1f / num2); + Rectangle rectangle = new Rectangle(0, 0, BGTexture.Width, BGTexture.Height); + Vector2 zero = Vector2.Zero; + + switch (Layers) + { + case 0: + { + zero.Y += 200f; + break; + } + case 1: + { + zero.Y += 0f; + break; + } + case 2: + { + zero.Y += 0f; + break; + } + case 3: + { + zero.Y += 0f; + break; + } + case 4: + { + zero.Y += 0f; + break; + } + } + + vector2 *= Scale; + + zero.Y -= num; + float LoopWidth = Scale * rectangle.Width; + float LoopHeight = Scale * rectangle.Height; + int LoopX = (int)((vector.X * vector3.X - vector2.X + zero.X - (Main.screenWidth >> 1)) / LoopWidth); + int LoopY = (int)((vector.Y * vector3.Y - vector2.Y + zero.Y - (Main.screenWidth >> 1)) / LoopWidth); + + for (int i = LoopY - 2; i < LoopY + 4 + (int)(Main.screenWidth / LoopHeight); i++) + { + for (int j = LoopX - 2; j < LoopX + 4 + (int)(Main.screenWidth / LoopWidth); j++) + { + Vector2 drawPosition = (new Vector2(j * Scale * (rectangle.Width / vector3.X), playerDrawPosition) + vector2 - vector) * vector3 + vector - Main.screenPosition - vector2 + zero; + + var frame = rectangle; + var color = Color.White * Transparency; + + Main.spriteBatch.Draw(BGTexture, drawPosition, frame, color, 0f, Vector2.Zero, Scale, SpriteEffects.None, 0f); + } + } + } + } + } private static void DrawBurrowsBG() { if (Main.LocalPlayer.InModBiome(ModContent.GetInstance())) { - Transparency += TransitionSpeed; + Transparency += 1f; if (Transparency > 1f) Transparency = 1f; diff --git a/Backgrounds/SunkenSeaShoresBG0.png b/Backgrounds/SunkenSeaShoresBG0.png new file mode 100644 index 0000000000..272e84a3d0 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG0.png differ diff --git a/Backgrounds/SunkenSeaShoresBG1.png b/Backgrounds/SunkenSeaShoresBG1.png new file mode 100644 index 0000000000..0d7faa83b7 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG1.png differ diff --git a/Backgrounds/SunkenSeaShoresBG2.png b/Backgrounds/SunkenSeaShoresBG2.png new file mode 100644 index 0000000000..ddaffc2a82 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG2.png differ diff --git a/Backgrounds/SunkenSeaShoresBG3.png b/Backgrounds/SunkenSeaShoresBG3.png new file mode 100644 index 0000000000..e9668359e5 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG3.png differ diff --git a/Backgrounds/SunkenSeaShoresBG4.png b/Backgrounds/SunkenSeaShoresBG4.png new file mode 100644 index 0000000000..4922846eb0 Binary files /dev/null and b/Backgrounds/SunkenSeaShoresBG4.png differ