From 4d9f236efcbbd816bbda02063877a7e270f30e75 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Thu, 3 Aug 2023 07:51:36 -0500 Subject: [PATCH] Sky optimizations and other random crap. --- Skies/AstralSky.cs | 1 + Skies/AstralSkyDesert.cs | 103 ++++++++++++++++++-------------------- Skies/AstralSkySnow.cs | 37 +++++++------- Skies/AstralSkySurface.cs | 38 +++++++------- Skies/BossRushSky.cs | 7 ++- Skies/BrimstoneCragSky.cs | 13 ++--- Skies/CryogenSky.cs | 2 + Skies/MonolithSky.cs | 6 +-- Skies/SCalSky.cs | 8 ++- Skies/SulphurSeaSky.cs | 41 +++++---------- 10 files changed, 118 insertions(+), 138 deletions(-) diff --git a/Skies/AstralSky.cs b/Skies/AstralSky.cs index 2f4cc66aeb..8cbbae6aa5 100644 --- a/Skies/AstralSky.cs +++ b/Skies/AstralSky.cs @@ -33,6 +33,7 @@ namespace CalamityMod.Skies { skyActive = true; } + public override Color OnTileColor(Color inColor) { return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); diff --git a/Skies/AstralSkyDesert.cs b/Skies/AstralSkyDesert.cs index 6cad1d967f..e267226be0 100644 --- a/Skies/AstralSkyDesert.cs +++ b/Skies/AstralSkyDesert.cs @@ -40,82 +40,81 @@ namespace CalamityMod.Skies public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) { - //small worlds, default draw height + // Small worlds, default draw height int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - //medium worlds + // Medium worlds if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) - { AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - } - //large worlds (and anything bigger) + // Large worlds (and anything bigger) if (Main.maxTilesX >= 8400) - { AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; - } - //Background from here starting from the back layer to the front layer + // Background from here starting from the back layer to the front layer if (maxDepth >= 9f && minDepth < 9f) { - float screenParralaxMultiplier = 0.4f; + float screenParralaxMultiplier = 0.16f; Texture2D texture = CalamityMod.AstralSurfaceHorizon; float scale = 2.0f; - int x = (int)(Main.screenPosition.X * 0.4f * screenParralaxMultiplier); + int x = (int)(Main.screenPosition.X * screenParralaxMultiplier); x %= (int)(texture.Width * scale); - int y = (int)(Main.screenPosition.Y * 0.4f * screenParralaxMultiplier); - y -= 1380; //1000 + int y = (int)(Main.screenPosition.Y * screenParralaxMultiplier); + y -= 1380; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 8f && minDepth < 8f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralDesertSurfaceFar; + float scale = 2.0f; + int x = (int)(Main.screenPosition.X * 0.5f * screenParralaxMultiplier); + x %= (int)(texture.Width * scale); + int y = (int)(Main.screenPosition.Y * 0.45f * screenParralaxMultiplier); + y -= 1520; // 1000 + for (int k = -1; k <= 1; k++) { - float screenParralaxMultiplier = 0.4f; - Texture2D texture = CalamityMod.AstralDesertSurfaceFar; - float scale = 2.0f; - int x = (int)(Main.screenPosition.X * 0.5f * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); - int y = (int)(Main.screenPosition.Y * 0.45f * screenParralaxMultiplier); - y -= 1520; //1000 - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); - } + var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); + spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); } - if (maxDepth >= 7f && minDepth < 7f) + } + + if (maxDepth >= 7f && minDepth < 7f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralDesertSurfaceMiddle; + float scale = 2.0f; + int x = (int)(Main.screenPosition.X * 0.8f * screenParralaxMultiplier); + x %= (int)(texture.Width * scale); + int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); + y -= 1900; // 1000 + for (int k = -1; k <= 1; k++) { - float screenParralaxMultiplier = 0.4f; - Texture2D texture = CalamityMod.AstralDesertSurfaceMiddle; - float scale = 2.0f; - int x = (int)(Main.screenPosition.X * 0.8f * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); - int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); - y -= 1900; //1000 - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); - } + var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); + spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); } - if (maxDepth >= 6f && minDepth < 6f) + } + + if (maxDepth >= 6f && minDepth < 6f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralDesertSurfaceClose; + float scale = 2.0f; + int x = (int)(Main.screenPosition.X * 1.0f * screenParralaxMultiplier); + x %= (int)(texture.Width * scale); + int y = (int)(Main.screenPosition.Y * 0.55f * screenParralaxMultiplier); + y -= 2050; // 1000 + for (int k = -1; k <= 1; k++) { - float screenParralaxMultiplier = 0.4f; - Texture2D texture = CalamityMod.AstralDesertSurfaceClose; - float scale = 2.0f; - int x = (int)(Main.screenPosition.X * 1.0f * screenParralaxMultiplier); - x %= (int)(texture.Width * scale); - int y = (int)(Main.screenPosition.Y * 0.55f * screenParralaxMultiplier); - y -= 2050; //1000 - for (int k = -1; k <= 1; k++) - { - var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); - spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); - } + var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); + spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); } + } } public override void Update(GameTime gameTime) @@ -124,13 +123,9 @@ namespace CalamityMod.Skies skyActive = false; if (skyActive && opacity < 1f) - { opacity += 0.02f; - } else if (!skyActive && opacity > 0f) - { opacity -= 0.02f; - } } public override float GetCloudAlpha() diff --git a/Skies/AstralSkySnow.cs b/Skies/AstralSkySnow.cs index 1a3990c0d3..20dd2041e7 100644 --- a/Skies/AstralSkySnow.cs +++ b/Skies/AstralSkySnow.cs @@ -33,6 +33,7 @@ namespace CalamityMod.Skies { skyActive = true; } + public override Color OnTileColor(Color inColor) { return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); @@ -40,37 +41,34 @@ namespace CalamityMod.Skies public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) { - //small worlds, default draw height + // Small worlds, default draw height int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - //medium worlds + // Medium worlds if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) - { AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - } - //large worlds (and anything bigger) + // Large worlds (and anything bigger) if (Main.maxTilesX >= 8400) - { AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; - } - //Background from here starting from the back layer to the front layer + // Background from here starting from the back layer to the front layer if (maxDepth >= 9f && minDepth < 9f) { - float screenParralaxMultiplier = 0.4f; + float screenParralaxMultiplier = 0.16f; Texture2D texture = CalamityMod.AstralSurfaceHorizon; float scale = 2.0f; - int x = (int)(Main.screenPosition.X * 0.4f * screenParralaxMultiplier); + int x = (int)(Main.screenPosition.X * screenParralaxMultiplier); x %= (int)(texture.Width * scale); - int y = (int)(Main.screenPosition.Y * 0.4f * screenParralaxMultiplier); - y -= 1380; //1000 + int y = (int)(Main.screenPosition.Y * screenParralaxMultiplier); + y -= 1380; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(116, 96, 164, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 8f && minDepth < 8f) { float screenParralaxMultiplier = 0.4f; @@ -79,13 +77,14 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 0.5f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.45f * screenParralaxMultiplier); - y -= 1520; //1000 + y -= 1520; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(116, 96, 164, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 7f && minDepth < 7f) { float screenParralaxMultiplier = 0.4f; @@ -94,13 +93,14 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 0.8f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); - y -= 1900; //1000 + y -= 1900; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(116, 96, 164, 255) * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 6f && minDepth < 6f) { float screenParralaxMultiplier = 0.4f; @@ -109,7 +109,7 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 0.9f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.55f * screenParralaxMultiplier); - y -= 1880; //1000 + y -= 1880; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); @@ -123,6 +123,7 @@ namespace CalamityMod.Skies spriteBatch.Draw(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.7f * opacity, 0f, new Vector2(0f, (float)AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 5f && minDepth < 5f) { float screenParralaxMultiplier = 0.4f; @@ -131,7 +132,7 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 1.1f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.6f * screenParralaxMultiplier); - y -= 2100; //1000 + y -= 2100; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); @@ -153,13 +154,9 @@ namespace CalamityMod.Skies skyActive = false; if (skyActive && opacity < 1f) - { opacity += 0.02f; - } else if (!skyActive && opacity > 0f) - { opacity -= 0.02f; - } } public override float GetCloudAlpha() diff --git a/Skies/AstralSkySurface.cs b/Skies/AstralSkySurface.cs index c8ff81bdf2..1c95e64e8a 100644 --- a/Skies/AstralSkySurface.cs +++ b/Skies/AstralSkySurface.cs @@ -33,6 +33,7 @@ namespace CalamityMod.Skies { skyActive = true; } + public override Color OnTileColor(Color inColor) { return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); @@ -40,36 +41,34 @@ namespace CalamityMod.Skies public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) { - //small worlds, default draw height + // Small worlds, default draw height int AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 2; - //medium worlds + // Medium worlds if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) - { AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 4; - } - //large worlds (and anything bigger) + // Large worlds (and anything bigger) if (Main.maxTilesX >= 8400) - { AstralBiomeHeight = (World.AstralBiome.YStart + (int)Main.worldSurface) / 140; - } - //Background from here starting from the back layer to the front layer + + // Background from here starting from the back layer to the front layer if (maxDepth >= 9f && minDepth < 9f) { - float screenParralaxMultiplier = 0.4f; + float screenParralaxMultiplier = 0.16f; Texture2D texture = CalamityMod.AstralSurfaceHorizon; float scale = 2.0f; - int x = (int)(Main.screenPosition.X * 0.4f * screenParralaxMultiplier); + int x = (int)(Main.screenPosition.X * screenParralaxMultiplier); x %= (int)(texture.Width * scale); - int y = (int)(Main.screenPosition.Y * 0.4f * screenParralaxMultiplier); - y -= 1380; //1000 + int y = (int)(Main.screenPosition.Y * screenParralaxMultiplier); + y -= 1380; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 8f && minDepth < 8f) { float screenParralaxMultiplier = 0.4f; @@ -78,13 +77,14 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 0.5f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.45f * screenParralaxMultiplier); - y -= 1520; //1000 + y -= 1520; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, new Color(63, 51, 90, 255) * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 7f && minDepth < 7f) { float screenParralaxMultiplier = 0.4f; @@ -93,7 +93,7 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 0.8f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); - y -= 1900; //1000 + y -= 1900; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); @@ -107,6 +107,7 @@ namespace CalamityMod.Skies spriteBatch.Draw(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.5f * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 6f && minDepth < 6f) { float screenParralaxMultiplier = 0.4f; @@ -115,7 +116,7 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 0.9f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.55f * screenParralaxMultiplier); - y -= 1880; //1000 + y -= 1880; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); @@ -129,6 +130,7 @@ namespace CalamityMod.Skies spriteBatch.Draw(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.7f * opacity, 0f, new Vector2(0f, AstralBiomeHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 5f && minDepth < 5f) { float screenParralaxMultiplier = 0.4f; @@ -137,7 +139,7 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 1.1f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.6f * screenParralaxMultiplier); - y -= 2100; //1000 + y -= 2100; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); @@ -160,13 +162,9 @@ namespace CalamityMod.Skies skyActive = false; if (skyActive && opacity < 1f) - { opacity += 0.02f; - } else if (!skyActive && opacity > 0f) - { opacity -= 0.02f; - } } public override float GetCloudAlpha() diff --git a/Skies/BossRushSky.cs b/Skies/BossRushSky.cs index d6dbaf2463..3663cd663c 100644 --- a/Skies/BossRushSky.cs +++ b/Skies/BossRushSky.cs @@ -18,6 +18,7 @@ namespace CalamityMod.Skies public static float IncrementalInterest = 0f; public static float CurrentInterestMin = 0f; public static bool ShouldDrawRegularly; + public static Color GeneralColor => Color.Lerp(Color.LightGray, Color.Black, BossRushEvent.WhiteDimness) * 0.2f; public static bool DetermineDrawEligibility() @@ -28,12 +29,10 @@ namespace CalamityMod.Skies { if (useEffect) SkyManager.Instance.Activate("CalamityMod:BossRush"); - else - { SkyManager.Instance.Deactivate("CalamityMod:BossRush", new object[0]); - } } + if (useEffect != Filters.Scene["CalamityMod:BossRush"].IsActive()) { if (useEffect) @@ -51,6 +50,7 @@ namespace CalamityMod.Skies { if (Intensity < 1f) Intensity += 0.03f; + CurrentInterest = MathHelper.Clamp(CurrentInterest - 0.005f, CurrentInterestMin, 1f); IncrementalInterest = MathHelper.Lerp(IncrementalInterest, CurrentInterest, 0.085f); IdleTimer += MathHelper.Lerp(0.04f, 0.1f, IncrementalInterest); @@ -96,7 +96,6 @@ namespace CalamityMod.Skies fadeToWhite *= Utils.GetLerpValue(BossRushEvent.EndVisualEffectTime - 5f, BossRushEvent.EndVisualEffectTime - 25f, BossRushEvent.EndTimer, true); float backScale = MathHelper.Lerp(0.01f, 8f, fadeToWhite); Color backFadeColor = Color.White * fadeToWhite * 0.64f; - spriteBatch.Draw(whiteTexture, screenCenter, null, backFadeColor, 0f, whiteTexture.Size() * 0.5f, backScale, SpriteEffects.None, 0f); } diff --git a/Skies/BrimstoneCragSky.cs b/Skies/BrimstoneCragSky.cs index 81f01080bf..3c033becf8 100644 --- a/Skies/BrimstoneCragSky.cs +++ b/Skies/BrimstoneCragSky.cs @@ -13,6 +13,7 @@ namespace CalamityMod.Skies public class BrimstoneCragSky : CustomSky { public int skyActiveLeeway = 0; + public class Cinder { public int Time; @@ -23,6 +24,7 @@ namespace CalamityMod.Skies public Color DrawColor; public Vector2 Velocity; public Vector2 Center; + public Cinder(int lifetime, int identity, float depth, Color color, Vector2 startingPosition, Vector2 startingVelocity) { Lifetime = lifetime; @@ -51,18 +53,16 @@ namespace CalamityMod.Skies if (!Main.LocalPlayer.Calamity().ZoneCalamity || Main.gameMenu) { skyActive = false; - if (skyActiveLeeway > 0) skyActiveLeeway--; + if (skyActiveLeeway > 0) + skyActiveLeeway--; } - else if (skyActiveLeeway < 60) skyActiveLeeway++; + else if (skyActiveLeeway < 60) + skyActiveLeeway++; if (skyActive && opacity < 1f) - { opacity += 0.02f; - } else if (!skyActive && opacity > 0f) - { opacity -= 0.02f; - } static Color selectCinderColor() { @@ -126,6 +126,7 @@ namespace CalamityMod.Skies offsetDrawColor.A = 0; spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f * scaleFade, SpriteEffects.None, 0f); } + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * scaleFade, SpriteEffects.None, 0f); } } diff --git a/Skies/CryogenSky.cs b/Skies/CryogenSky.cs index 4f2efb2418..28a56df119 100644 --- a/Skies/CryogenSky.cs +++ b/Skies/CryogenSky.cs @@ -20,6 +20,7 @@ namespace CalamityMod.Skies public Vector2 Center; public SpriteEffects DirectionEffect; } + public int CryogenIndex = -1; public float FadeInCountdown = 0f; public float FadeoutTimer = 0f; @@ -104,6 +105,7 @@ namespace CalamityMod.Skies break; } } + return CryogenIndex != -1; } diff --git a/Skies/MonolithSky.cs b/Skies/MonolithSky.cs index 235d5429e0..ff23c053d4 100644 --- a/Skies/MonolithSky.cs +++ b/Skies/MonolithSky.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Skies public Color DrawColor; public Vector2 Velocity; public Vector2 Center; + public Cinder(int lifetime, int identity, float depth, Color color, Vector2 startingPosition, Vector2 startingVelocity) { Lifetime = lifetime; @@ -51,13 +52,9 @@ namespace CalamityMod.Skies skyActive = false; if (skyActive && opacity < 1f) - { opacity += 0.02f; - } else if (!skyActive && opacity > 0f) - { opacity -= 0.02f; - } static Color selectCinderColor() { @@ -124,6 +121,7 @@ namespace CalamityMod.Skies offsetDrawColor.A = 0; spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); } + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale, SpriteEffects.None, 0f); } } diff --git a/Skies/SCalSky.cs b/Skies/SCalSky.cs index e169e91341..0e816ec2dd 100644 --- a/Skies/SCalSky.cs +++ b/Skies/SCalSky.cs @@ -25,6 +25,7 @@ namespace CalamityMod.Skies public Color DrawColor; public Vector2 Velocity; public Vector2 Center; + public Cinder(int lifetime, int identity, float depth, Color color, Vector2 startingPosition, Vector2 startingVelocity) { Lifetime = lifetime; @@ -106,6 +107,7 @@ namespace CalamityMod.Skies return 5.6f; } } + public static float OverridingIntensity = 0f; public override void Update(GameTime gameTime) @@ -182,6 +184,7 @@ namespace CalamityMod.Skies return (1f - Utils.SmoothStep(3000f, 6000f, x)) * intensityFactor; } + return 0f; } @@ -191,9 +194,8 @@ namespace CalamityMod.Skies { int SCalType = ModContent.NPCType(); if (SCalIndex >= 0 && Main.npc[SCalIndex].active && Main.npc[SCalIndex].type == SCalType) - { return true; - } + SCalIndex = -1; for (int i = 0; i < Main.npc.Length; i++) { @@ -203,6 +205,7 @@ namespace CalamityMod.Skies break; } } + return SCalIndex != -1; } @@ -232,6 +235,7 @@ namespace CalamityMod.Skies offsetDrawColor.A = 0; spriteBatch.Draw(cinderTexture, offsetDrawPosition, null, offsetDrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale * 1.5f, SpriteEffects.None, 0f); } + spriteBatch.Draw(cinderTexture, drawPosition, null, Cinders[i].DrawColor, 0f, cinderTexture.Size() * 0.5f, Cinders[i].Scale, SpriteEffects.None, 0f); } } diff --git a/Skies/SulphurSeaSky.cs b/Skies/SulphurSeaSky.cs index 16c67e878c..37fd99fd16 100644 --- a/Skies/SulphurSeaSky.cs +++ b/Skies/SulphurSeaSky.cs @@ -36,35 +36,27 @@ namespace CalamityMod.Skies public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) { if (maxDepth >= 4f && minDepth < 4f) - { spriteBatch.Draw(CalamityMod.SulphurSeaSky, new Rectangle(0, (int)(-Main.screenPosition.Y / 6f) + 1300, Main.screenWidth, Main.screenHeight), Color.Lerp(Main.ColorOfTheSkies, Color.LightSeaGreen, 0.33f) * 0.2f * opacity); - } - //if (maxDepth >= 1f && minDepth < 1f) - //{ - // spriteBatch.Draw(CalamityMod.SulphurSeaSkyFront, new Rectangle(0, (int)(-Main.screenPosition.Y / 6f) + 1300, Main.screenWidth, Main.screenHeight), Color.Lerp(Main.ColorOfTheSkies, Color.White, 0.33f) * 1.5f * opacity); - //} - - //small worlds, default draw height + + // Small worlds, default draw height int sulphurSeaHeight = (World.SulphurousSea.YStart + (int)Main.worldSurface) / 2; - //medium worlds + // Medium worlds if (Main.maxTilesX >= 6400 && Main.maxTilesX < 8400) - { sulphurSeaHeight = (World.SulphurousSea.YStart + (int)Main.worldSurface) / 5; - } - //large worlds (and anything bigger) + + // Large worlds (and anything bigger) if (Main.maxTilesX >= 8400) - { sulphurSeaHeight = (World.SulphurousSea.YStart + (int)Main.worldSurface) / 140; - } if (maxDepth >= 1f && minDepth < 1f) { - //Explantion on how to use this BG code for skies - //This changes the speed of the parralax, the closer the layer to the player the faster it should be + // Explantion on how to use this BG code for skies. + // This changes the speed of the parralax, the closer the layer to the player the faster it should be. float screenParralaxMultiplier = 0.4f; Texture2D texture = CalamityMod.SulphurSeaSkyFront; - //Vanila scales backgrounds to 250% size. Depending on what you might want to do you can change this if you wanted to make a non scaled bg. + + // Vanila scales backgrounds to 250% size. Depending on what you might want to do you can change this if you wanted to make a non scaled bg. float scale = 2.5f; //Keep in mind that y paralex should always be half of x's or it will feel odd compared to how terraria does it. @@ -72,7 +64,8 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 1f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); - //Y offset to align with whatever position you want it in the world (is affected by screenParralaxMultiplier as stated before). + + // Y offset to align with whatever position you want it in the world (is affected by screenParralaxMultiplier as stated before). y -= 1800; //this loops the BG horizontally. @@ -82,6 +75,7 @@ namespace CalamityMod.Skies spriteBatch.Draw(texture, pos - texture.Size() / 2f * scale, null, Color.LightSeaGreen * 0.5f * opacity, 0f, new Vector2(0f, (float)sulphurSeaHeight), scale, SpriteEffects.None, 0f); } } + if (maxDepth >= 3f && minDepth < 3f) { float screenParralaxMultiplier = 0.4f; @@ -90,7 +84,7 @@ namespace CalamityMod.Skies int x = (int)(Main.screenPosition.X * 1f * screenParralaxMultiplier); x %= (int)(texture.Width * scale); int y = (int)(Main.screenPosition.Y * 0.5f * screenParralaxMultiplier); - y -= 1800; //1000 + y -= 1800; // 1000 for (int k = -1; k <= 1; k++) { var pos = new Vector2(Main.screenWidth / 2f - x + texture.Width * k * scale, Main.screenHeight / 2f - y); @@ -105,18 +99,9 @@ namespace CalamityMod.Skies skyActive = false; if (skyActive && opacity < 1f) - { opacity += 0.02f; - } else if (!skyActive && opacity > 0f) - { opacity -= 0.02f; - } } - - //public override float GetCloudAlpha() - //{ - // return (1f - opacity) * 0.97f + 0.03f; - //} } }