diff --git a/Backgrounds/AstralDesertSurfaceBGStyle.cs b/Backgrounds/AstralDesertSurfaceBGStyle.cs index 89e9b30174..51d1c01ef7 100644 --- a/Backgrounds/AstralDesertSurfaceBGStyle.cs +++ b/Backgrounds/AstralDesertSurfaceBGStyle.cs @@ -4,14 +4,14 @@ namespace CalamityMod.Backgrounds { public class AstralDesertSurfaceBGStyle : ModSurfaceBackgroundStyle { - public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralDesertSurfaceFar"); + public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralDesertSurfaceMiddle"); + public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) { b -= 75f; - return BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralDesertSurfaceClose"); + return BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); } public override void ModifyFarFades(float[] fades, float transitionSpeed) diff --git a/Backgrounds/AstralSnowSurfaceBGStyle.cs b/Backgrounds/AstralSnowSurfaceBGStyle.cs index d8b0ea2aa4..993decd710 100644 --- a/Backgrounds/AstralSnowSurfaceBGStyle.cs +++ b/Backgrounds/AstralSnowSurfaceBGStyle.cs @@ -4,11 +4,11 @@ namespace CalamityMod.Backgrounds { public class AstralSnowSurfaceBGStyle : ModSurfaceBackgroundStyle { - public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSnowSurfaceFar"); + public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSnowSurfaceMiddle"); + public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceClose"); + public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); public override void ModifyFarFades(float[] fades, float transitionSpeed) { diff --git a/Backgrounds/AstralSurfaceBGStyle.cs b/Backgrounds/AstralSurfaceBGStyle.cs index c89b8c1c24..8c8a7ee21c 100644 --- a/Backgrounds/AstralSurfaceBGStyle.cs +++ b/Backgrounds/AstralSurfaceBGStyle.cs @@ -4,14 +4,14 @@ namespace CalamityMod.Backgrounds { public class AstralSurfaceBGStyle : ModSurfaceBackgroundStyle { - public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceFar"); + public override int ChooseFarTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); - public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceMiddle"); + public override int ChooseMiddleTexture() => BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); public override int ChooseCloseTexture(ref float scale, ref double parallax, ref float a, ref float b) { scale *= 0.75f; - return BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/AstralSurfaceClose"); + return BackgroundTextureLoader.GetBackgroundSlot("CalamityMod/Backgrounds/BlankPixel"); } public override void ModifyFarFades(float[] fades, float transitionSpeed) diff --git a/BiomeManagers/AbovegroundAstralDesertBiome.cs b/BiomeManagers/AbovegroundAstralDesertBiome.cs index ac0c11a09f..3f4148c87b 100644 --- a/BiomeManagers/AbovegroundAstralDesertBiome.cs +++ b/BiomeManagers/AbovegroundAstralDesertBiome.cs @@ -1,5 +1,6 @@ using CalamityMod.Systems; using Terraria; +using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; @@ -28,7 +29,17 @@ namespace CalamityMod.BiomeManagers public override void SpecialVisuals(Player player, bool isActive) { - player.ManageSpecialBiomeVisuals("CalamityMod:Astral", isActive); + if (SkyManager.Instance["CalamityMod:AstralDesert"] != null && isActive != SkyManager.Instance["CalamityMod:AstralDesert"].IsActive()) + { + if (isActive) + { + SkyManager.Instance.Activate("CalamityMod:AstralDesert"); + } + else + { + SkyManager.Instance.Deactivate("CalamityMod:AstralDesert"); + } + } } } } diff --git a/BiomeManagers/AbovegroundAstralSnowBiome.cs b/BiomeManagers/AbovegroundAstralSnowBiome.cs index c357c6812a..d837fe9c1e 100644 --- a/BiomeManagers/AbovegroundAstralSnowBiome.cs +++ b/BiomeManagers/AbovegroundAstralSnowBiome.cs @@ -1,5 +1,6 @@ using CalamityMod.Systems; using Terraria; +using Terraria.Graphics.Effects; using Terraria.ID; using Terraria.ModLoader; @@ -26,7 +27,17 @@ namespace CalamityMod.BiomeManagers public override void SpecialVisuals(Player player, bool isActive) { - player.ManageSpecialBiomeVisuals("CalamityMod:Astral", isActive); + if (SkyManager.Instance["CalamityMod:AstralSnow"] != null && isActive != SkyManager.Instance["CalamityMod:AstralSnow"].IsActive()) + { + if (isActive) + { + SkyManager.Instance.Activate("CalamityMod:AstralSnow"); + } + else + { + SkyManager.Instance.Deactivate("CalamityMod:AstralSnow"); + } + } } } diff --git a/CalamityMod.cs b/CalamityMod.cs index 739c1dd199..c4bd445dbe 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -96,7 +96,27 @@ namespace CalamityMod public static Asset rainOriginal; public static Asset manaOriginal; public static Asset carpetOriginal; + + //Astral Sky/BG public static Texture2D AstralSky; + public static Texture2D AstralSurfaceFront; + public static Texture2D AstralSurfaceFrontGlow; + public static Texture2D AstralSurfaceClose; + public static Texture2D AstralSurfaceCloseGlow; + public static Texture2D AstralSurfaceMiddle; + public static Texture2D AstralSurfaceMiddleGlow; + public static Texture2D AstralSurfaceFar; + public static Texture2D AstralSurfaceHorizon; + + //Astral Desert Sky/BG + public static Texture2D AstralDesertSurfaceClose; + public static Texture2D AstralDesertSurfaceMiddle; + public static Texture2D AstralDesertSurfaceFar; + + //Astral Snow Sky/BG + public static Texture2D AstralSnowSurfaceMiddle; + + //Sulpher Sea Sky/BG public static Texture2D SulphurSeaSky; public static Texture2D SulphurSeaSkyFront; public static Texture2D SulphurSeaSurface; @@ -275,7 +295,26 @@ namespace CalamityMod private void LoadClient() { + //Astral Sky/BG AstralSky = ModContent.Request("CalamityMod/Skies/AstralSky", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceFront = ModContent.Request("CalamityMod/Skies/AstralSurfaceFront", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceFrontGlow = ModContent.Request("CalamityMod/Skies/AstralSurfaceFrontGlow", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceClose = ModContent.Request("CalamityMod/Skies/AstralSurfaceClose", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceCloseGlow = ModContent.Request("CalamityMod/Skies/AstralSurfaceCloseGlow", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceMiddle = ModContent.Request("CalamityMod/Skies/AstralSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceMiddleGlow = ModContent.Request("CalamityMod/Skies/AstralSurfaceMiddleGlow", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceFar = ModContent.Request("CalamityMod/Skies/AstralSurfaceFar", AssetRequestMode.ImmediateLoad).Value; + AstralSurfaceHorizon = ModContent.Request("CalamityMod/Skies/AstralSurfaceHorizon", AssetRequestMode.ImmediateLoad).Value; + + //Astral Desert Sky/BG + AstralDesertSurfaceClose = ModContent.Request("CalamityMod/Skies/AstralDesertSurfaceClose", AssetRequestMode.ImmediateLoad).Value; + AstralDesertSurfaceMiddle = ModContent.Request("CalamityMod/Skies/AstralDesertSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; + AstralDesertSurfaceFar = ModContent.Request("CalamityMod/Skies/AstralDesertSurfaceFar", AssetRequestMode.ImmediateLoad).Value; + + //Astral Snow Sky/BG + AstralSnowSurfaceMiddle = ModContent.Request("CalamityMod/Skies/AstralSnowSurfaceMiddle", AssetRequestMode.ImmediateLoad).Value; + + //Sulpher Sea Sky/BG SulphurSeaSky = ModContent.Request("CalamityMod/Skies/SulphurSeaSky", AssetRequestMode.ImmediateLoad).Value; SulphurSeaSkyFront = ModContent.Request("CalamityMod/Skies/SulphurSeaSkyFront", AssetRequestMode.ImmediateLoad).Value; SulphurSeaSurface = ModContent.Request("CalamityMod/Skies/SulphurSeaSurface", AssetRequestMode.ImmediateLoad).Value; @@ -322,6 +361,8 @@ namespace CalamityMod SkyManager.Instance["CalamityMod:BrimstoneCrag"] = new BrimstoneCragSky(); SkyManager.Instance["CalamityMod:Astral"] = new AstralSky(); + SkyManager.Instance["CalamityMod:AstralDesert"] = new AstralSkyDesert(); + SkyManager.Instance["CalamityMod:AstralSnow"] = new AstralSkySnow(); SkyManager.Instance["CalamityMod:SulphurSea"] = new SulphurSeaSky(); SkyManager.Instance["CalamityMod:Cryogen"] = new CryogenSky(); SkyManager.Instance["CalamityMod:StormWeaverFlash"] = new StormWeaverFlashSky(); diff --git a/Skies/AstralDesertSurfaceClose.png b/Skies/AstralDesertSurfaceClose.png new file mode 100644 index 0000000000..c96ebe2cfd Binary files /dev/null and b/Skies/AstralDesertSurfaceClose.png differ diff --git a/Skies/AstralDesertSurfaceFar.png b/Skies/AstralDesertSurfaceFar.png new file mode 100644 index 0000000000..a2337a7d8f Binary files /dev/null and b/Skies/AstralDesertSurfaceFar.png differ diff --git a/Skies/AstralDesertSurfaceMiddle.png b/Skies/AstralDesertSurfaceMiddle.png new file mode 100644 index 0000000000..6b5c33dee8 Binary files /dev/null and b/Skies/AstralDesertSurfaceMiddle.png differ diff --git a/Skies/AstralSky.cs b/Skies/AstralSky.cs index 450cedb106..9ed0f69687 100644 --- a/Skies/AstralSky.cs +++ b/Skies/AstralSky.cs @@ -1,6 +1,8 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; +using Terraria.ModLoader; using Terraria.GameContent; using Terraria.Graphics.Effects; using Terraria.ID; @@ -14,7 +16,7 @@ namespace CalamityMod.Skies public override void Deactivate(params object[] args) { - skyActive = Main.LocalPlayer.Calamity().ZoneAstral; + skyActive = Main.LocalPlayer.Calamity().ZoneAstral && !Main.LocalPlayer.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && !Main.LocalPlayer.ZoneDesert && !Main.LocalPlayer.ZoneSnow; } public override void Reset() @@ -31,18 +33,23 @@ namespace CalamityMod.Skies { skyActive = true; } + public override Color OnTileColor(Color inColor) + { + return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); + } public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) { if (maxDepth >= 3.40282347E+38f && minDepth < 3.40282347E+38f) { - spriteBatch.Draw(CalamityMod.AstralSky, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Main.ColorOfTheSkies * opacity); + spriteBatch.Draw(CalamityMod.AstralSky, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White * opacity); //Terraria's conditions. if (Main.netMode != NetmodeID.Server) { for (int i = 0; i < Main.star.Length; i++) { + Star star = Main.star[i]; if (star == null) continue; @@ -51,8 +58,74 @@ namespace CalamityMod.Skies Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); - float posX = star.position.X * (Main.screenWidth / 800f); + float posX = star.position.X * (Main.screenWidth / 500f); float posY = star.position.Y * (Main.screenHeight / 600f); + Color astralcyan = new Color(100, 183, 255); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), astralcyan * star.twinkle * 0.952f * opacity, star.rotation, origin, (star.scale * star.twinkle) - 0.2f, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.2f, t2D.Height * 0.2f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 600f); + float posY = star.position.Y * (Main.screenHeight / 800f); + Color purple = new Color(201, 148, 255); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), purple * star.twinkle * 0.952f * opacity, star.rotation, origin, (star.scale * star.twinkle) + 0.2f, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.8f, t2D.Height * 0.8f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 200f); + float posY = star.position.Y * (Main.screenHeight / 900f); + Color yellow = new Color(255, 146, 73); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), yellow * star.twinkle * 0.952f * opacity, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 1000f); + float posY = star.position.Y * (Main.screenHeight / 200f); Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); @@ -60,6 +133,103 @@ namespace CalamityMod.Skies } } } + //Background from here starting from the back layer to the front layer + if (maxDepth >= 9f && minDepth < 9f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceHorizon; + float scale = 2.0f; + int x = (int)(Main.screenPosition.X * 0.4f * screenParralaxMultiplier); + x %= (int)(texture.Width * scale); + int y = (int)(Main.screenPosition.Y * 0.4f * 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, 0f), scale, SpriteEffects.None, 0f); + } + } + if (maxDepth >= 8f && minDepth < 8f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceFar; + 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, 0f), scale, SpriteEffects.None, 0f); + } + } + if (maxDepth >= 7f && minDepth < 7f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceMiddle; + 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, 0f), scale, SpriteEffects.None, 0f); + } + + Texture2D textureglow = CalamityMod.AstralSurfaceMiddleGlow; + 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(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.5f * opacity, 0f, new Vector2(0f, 0f), scale, SpriteEffects.None, 0f); + } + } + if (maxDepth >= 6f && minDepth < 6f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceClose; + float scale = 2.0f; + 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 + 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, 0f), scale, SpriteEffects.None, 0f); + } + + Texture2D textureglow = CalamityMod.AstralSurfaceCloseGlow; + 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(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.7f * opacity, 0f, new Vector2(0f, 0f), scale, SpriteEffects.None, 0f); + } + } + if (maxDepth >= 5f && minDepth < 5f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceFront; + float scale = 2.0f; + 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 + 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, 0f), scale, SpriteEffects.None, 0f); + } + + Texture2D textureglow = CalamityMod.AstralSurfaceFrontGlow; + 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(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.9f * opacity, 0f, new Vector2(0f, 0f), scale, SpriteEffects.None, 0f); + } + } } public override void Update(GameTime gameTime) diff --git a/Skies/AstralSky.png b/Skies/AstralSky.png index b30edb57db..4ba0ab38ae 100644 Binary files a/Skies/AstralSky.png and b/Skies/AstralSky.png differ diff --git a/Skies/AstralSkyDesert.cs b/Skies/AstralSkyDesert.cs new file mode 100644 index 0000000000..4cba1e87f1 --- /dev/null +++ b/Skies/AstralSkyDesert.cs @@ -0,0 +1,219 @@ +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria.ID; + +namespace CalamityMod.Skies +{ + public class AstralSkyDesert : CustomSky + { + private bool skyActive; + private float opacity; + + public override void Deactivate(params object[] args) + { + skyActive = Main.LocalPlayer.Calamity().ZoneAstral && !Main.LocalPlayer.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && Main.LocalPlayer.ZoneDesert && !Main.LocalPlayer.ZoneSnow; + } + + public override void Reset() + { + skyActive = false; + } + + public override bool IsActive() + { + return skyActive || opacity > 0f; + } + + public override void Activate(Vector2 position, params object[] args) + { + skyActive = true; + } + public override Color OnTileColor(Color inColor) + { + return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (maxDepth >= 3.40282347E+38f && minDepth < 3.40282347E+38f) + { + spriteBatch.Draw(CalamityMod.AstralSky, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White * opacity); + + //Terraria's conditions. + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 500f); + float posY = star.position.Y * (Main.screenHeight / 600f); + Color astralcyan = new Color(100, 183, 255); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), astralcyan * star.twinkle * 0.952f * opacity, star.rotation, origin, (star.scale * star.twinkle) - 0.2f, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.2f, t2D.Height * 0.2f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 600f); + float posY = star.position.Y * (Main.screenHeight / 800f); + Color purple = new Color(201, 148, 255); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), purple * star.twinkle * 0.952f * opacity, star.rotation, origin, (star.scale * star.twinkle) + 0.2f, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.8f, t2D.Height * 0.8f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 200f); + float posY = star.position.Y * (Main.screenHeight / 900f); + Color yellow = new Color(255, 146, 73); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), yellow * star.twinkle * 0.952f * opacity, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 1000f); + float posY = star.position.Y * (Main.screenHeight / 200f); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), Color.White * star.twinkle * 0.952f * opacity, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); + } + } + } + //Background from here starting from the back layer to the front layer + if (maxDepth >= 9f && minDepth < 9f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceHorizon; + float scale = 2.0f; + int x = (int)(Main.screenPosition.X * 0.4f * screenParralaxMultiplier); + x %= (int)(texture.Width * scale); + int y = (int)(Main.screenPosition.Y * 0.4f * 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, 0f), 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++) + { + 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, 0f), scale, SpriteEffects.None, 0f); + } + } + 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++) + { + 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, 0f), scale, SpriteEffects.None, 0f); + } + } + 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++) + { + 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, 0f), scale, SpriteEffects.None, 0f); + } + } + } + + public override void Update(GameTime gameTime) + { + if (!Main.LocalPlayer.Calamity().ZoneAstral || Main.gameMenu) + 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; + } + } +} diff --git a/Skies/AstralSkySnow.cs b/Skies/AstralSkySnow.cs new file mode 100644 index 0000000000..66328c9071 --- /dev/null +++ b/Skies/AstralSkySnow.cs @@ -0,0 +1,248 @@ +using CalamityMod.Systems; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.ModLoader; +using Terraria.GameContent; +using Terraria.Graphics.Effects; +using Terraria.ID; + +namespace CalamityMod.Skies +{ + public class AstralSkySnow : CustomSky + { + private bool skyActive; + private float opacity; + + public override void Deactivate(params object[] args) + { + skyActive = Main.LocalPlayer.Calamity().ZoneAstral && !Main.LocalPlayer.ZoneDungeon && BiomeTileCounterSystem.AstralTiles > 950 && !Main.LocalPlayer.ZoneDesert && Main.LocalPlayer.ZoneSnow; + } + + public override void Reset() + { + skyActive = false; + } + + public override bool IsActive() + { + return skyActive || opacity > 0f; + } + + public override void Activate(Vector2 position, params object[] args) + { + skyActive = true; + } + public override Color OnTileColor(Color inColor) + { + return Color.Lerp(inColor, new Color(63, 51, 90, inColor.A), opacity); + } + + public override void Draw(SpriteBatch spriteBatch, float minDepth, float maxDepth) + { + if (maxDepth >= 3.40282347E+38f && minDepth < 3.40282347E+38f) + { + spriteBatch.Draw(CalamityMod.AstralSky, new Rectangle(0, 0, Main.screenWidth, Main.screenHeight), Color.White * opacity); + + //Terraria's conditions. + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 500f); + float posY = star.position.Y * (Main.screenHeight / 600f); + Color astralcyan = new Color(100, 183, 255); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), astralcyan * star.twinkle * 0.952f * opacity, star.rotation, origin, (star.scale * star.twinkle) - 0.2f, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.2f, t2D.Height * 0.2f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 600f); + float posY = star.position.Y * (Main.screenHeight / 800f); + Color purple = new Color(201, 148, 255); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), purple * star.twinkle * 0.952f * opacity, star.rotation, origin, (star.scale * star.twinkle) + 0.2f, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.8f, t2D.Height * 0.8f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 200f); + float posY = star.position.Y * (Main.screenHeight / 900f); + Color yellow = new Color(255, 146, 73); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), yellow * star.twinkle * 0.952f * opacity, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); + } + } + if (Main.netMode != NetmodeID.Server) + { + for (int i = 0; i < Main.star.Length; i++) + { + + Star star = Main.star[i]; + if (star == null) + continue; + + Texture2D t2D = TextureAssets.Star[star.type].Value; + Vector2 origin = new Vector2(t2D.Width * 0.5f, t2D.Height * 0.5f); + + int bgTop = (int)((-Main.screenPosition.Y) / (Main.worldSurface * 16.0 - 600.0) * 200.0); + float posX = star.position.X * (Main.screenWidth / 1000f); + float posY = star.position.Y * (Main.screenHeight / 200f); + + Vector2 position = new Vector2(posX + origin.X, posY + origin.Y + bgTop); + + spriteBatch.Draw(t2D, position, new Rectangle(0, 0, t2D.Width, t2D.Height), Color.White * star.twinkle * 0.952f * opacity, star.rotation, origin, star.scale * star.twinkle, SpriteEffects.None, 0f); + } + } + } + //Background from here starting from the back layer to the front layer + if (maxDepth >= 9f && minDepth < 9f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceHorizon; + float scale = 2.0f; + int x = (int)(Main.screenPosition.X * 0.4f * screenParralaxMultiplier); + x %= (int)(texture.Width * scale); + int y = (int)(Main.screenPosition.Y * 0.4f * 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, 0f), scale, SpriteEffects.None, 0f); + } + } + if (maxDepth >= 8f && minDepth < 8f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceFar; + 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(116, 96, 164, 255) * opacity, 0f, new Vector2(0f, 0f), scale, SpriteEffects.None, 0f); + } + } + if (maxDepth >= 7f && minDepth < 7f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSnowSurfaceMiddle; + 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(116, 96, 164, 255) * opacity, 0f, new Vector2(0f, 0f), scale, SpriteEffects.None, 0f); + } + } + if (maxDepth >= 6f && minDepth < 6f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceClose; + float scale = 2.0f; + 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 + 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, 0f), scale, SpriteEffects.None, 0f); + } + + Texture2D textureglow = CalamityMod.AstralSurfaceCloseGlow; + 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(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.7f * opacity, 0f, new Vector2(0f, 0f), scale, SpriteEffects.None, 0f); + } + } + if (maxDepth >= 5f && minDepth < 5f) + { + float screenParralaxMultiplier = 0.4f; + Texture2D texture = CalamityMod.AstralSurfaceFront; + float scale = 2.0f; + 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 + 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, 0f), scale, SpriteEffects.None, 0f); + } + + Texture2D textureglow = CalamityMod.AstralSurfaceFrontGlow; + 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(textureglow, pos - texture.Size() / 2f * scale, null, Color.White * 0.9f * opacity, 0f, new Vector2(0f, 0f), scale, SpriteEffects.None, 0f); + } + } + } + + public override void Update(GameTime gameTime) + { + if (!Main.LocalPlayer.Calamity().ZoneAstral || Main.gameMenu) + 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; + } + } +} diff --git a/Skies/AstralSnowSurfaceMiddle.png b/Skies/AstralSnowSurfaceMiddle.png new file mode 100644 index 0000000000..ff4e5fc236 Binary files /dev/null and b/Skies/AstralSnowSurfaceMiddle.png differ diff --git a/Skies/AstralSurfaceClose.png b/Skies/AstralSurfaceClose.png new file mode 100644 index 0000000000..166e8bc48d Binary files /dev/null and b/Skies/AstralSurfaceClose.png differ diff --git a/Skies/AstralSurfaceCloseGlow.png b/Skies/AstralSurfaceCloseGlow.png new file mode 100644 index 0000000000..3fafef6c36 Binary files /dev/null and b/Skies/AstralSurfaceCloseGlow.png differ diff --git a/Skies/AstralSurfaceFar.png b/Skies/AstralSurfaceFar.png new file mode 100644 index 0000000000..de6901e9e4 Binary files /dev/null and b/Skies/AstralSurfaceFar.png differ diff --git a/Skies/AstralSurfaceFront.png b/Skies/AstralSurfaceFront.png new file mode 100644 index 0000000000..d9db0020e9 Binary files /dev/null and b/Skies/AstralSurfaceFront.png differ diff --git a/Skies/AstralSurfaceFrontGlow.png b/Skies/AstralSurfaceFrontGlow.png new file mode 100644 index 0000000000..6fca957aaa Binary files /dev/null and b/Skies/AstralSurfaceFrontGlow.png differ diff --git a/Skies/AstralSurfaceHorizon.png b/Skies/AstralSurfaceHorizon.png new file mode 100644 index 0000000000..8f448fb3b4 Binary files /dev/null and b/Skies/AstralSurfaceHorizon.png differ diff --git a/Skies/AstralSurfaceMiddle.png b/Skies/AstralSurfaceMiddle.png new file mode 100644 index 0000000000..d3f984c001 Binary files /dev/null and b/Skies/AstralSurfaceMiddle.png differ diff --git a/Skies/AstralSurfaceMiddleGlow.png b/Skies/AstralSurfaceMiddleGlow.png new file mode 100644 index 0000000000..30f1c4e6d6 Binary files /dev/null and b/Skies/AstralSurfaceMiddleGlow.png differ diff --git a/Tiles/Astral/AstralGrass.cs b/Tiles/Astral/AstralGrass.cs index 8fd26c3032..cd9b2ed511 100644 --- a/Tiles/Astral/AstralGrass.cs +++ b/Tiles/Astral/AstralGrass.cs @@ -35,11 +35,140 @@ namespace CalamityMod.Tiles.Astral TileID.Sets.NeedsGrassFramingDirt[Type] = ModContent.TileType(); TileID.Sets.CanBeDugByShovel[Type] = true; } + int animationFrameWidth = 288; public override void NumDust(int i, int j, bool fail, ref int Type) { Type = fail ? 1 : 3; } + public override void RandomUpdate(int i, int j) + { + Tile tile = Main.tile[i, j]; + Tile up = Main.tile[i, j - 1]; + Tile up2 = Main.tile[i, j - 2]; + //place Astral Wild Grass + if (WorldGen.genRand.Next(10) == 0 && !up.HasTile && !up2.HasTile && !(up.LiquidAmount > 0 && up2.LiquidAmount > 0) && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + { + up.TileType = (ushort)ModContent.TileType(); + up.HasTile = true; + up.TileFrameY = 0; + + //20 different frames, choose a random one + up.TileFrameX = (short)(WorldGen.genRand.Next(20) * 18); + WorldGen.SquareTileFrame(i, j - 1, true); + + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + } + } + //place Astral Short Grass + if (WorldGen.genRand.Next(10) == 0 && !up.HasTile && !up2.HasTile && !(up.LiquidAmount > 0 && up2.LiquidAmount > 0) && !tile.LeftSlope && !tile.RightSlope && !tile.IsHalfBlock) + { + up.TileType = (ushort)ModContent.TileType(); + up.HasTile = true; + up.TileFrameY = 0; + + //23 different frames, choose a random one + up.TileFrameX = (short)(WorldGen.genRand.Next(23) * 18); + WorldGen.SquareTileFrame(i, j - 1, true); + + if (Main.netMode == NetmodeID.Server) + { + NetMessage.SendTileSquare(-1, i, j - 1, 3, TileChangeType.None); + } + } + } + public override void AnimateIndividualTile(int type, int i, int j, ref int frameXOffset, ref int frameYOffset) + { + int uniqueAnimationFrameX = 0; + int xPos = i % 4; + int yPos = j % 4; + switch (xPos) + { + case 0: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 0; + break; + case 1: + uniqueAnimationFrameX = 0; + break; + case 2: + uniqueAnimationFrameX = 1; + break; + case 3: + uniqueAnimationFrameX = 1; + break; + default: + uniqueAnimationFrameX = 0; + break; + } + break; + case 1: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 1; + break; + case 1: + uniqueAnimationFrameX = 0; + break; + case 2: + uniqueAnimationFrameX = 1; + break; + case 3: + uniqueAnimationFrameX = 1; + break; + default: + uniqueAnimationFrameX = 0; + break; + } + break; + case 2: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 1; + break; + case 1: + uniqueAnimationFrameX = 0; + break; + case 2: + uniqueAnimationFrameX = 0; + break; + case 3: + uniqueAnimationFrameX = 1; + break; + default: + uniqueAnimationFrameX = 0; + break; + } + break; + case 3: + switch (yPos) + { + case 0: + uniqueAnimationFrameX = 0; + break; + case 1: + uniqueAnimationFrameX = 1; + break; + case 2: + uniqueAnimationFrameX = 0; + break; + case 3: + uniqueAnimationFrameX = 1; + break; + default: + uniqueAnimationFrameX = 0; + break; + } + break; + } + frameXOffset = uniqueAnimationFrameX * animationFrameWidth; + } public override void KillTile(int i, int j, ref bool fail, ref bool effectOnly, ref bool noItem) { diff --git a/Tiles/Astral/AstralGrass.png b/Tiles/Astral/AstralGrass.png index 18908d3796..db79ac77d2 100644 Binary files a/Tiles/Astral/AstralGrass.png and b/Tiles/Astral/AstralGrass.png differ diff --git a/Tiles/Astral/AstralVines.cs b/Tiles/Astral/AstralVines.cs index 3199f85196..f820e3d0f0 100644 --- a/Tiles/Astral/AstralVines.cs +++ b/Tiles/Astral/AstralVines.cs @@ -1,4 +1,5 @@ -using CalamityMod.Dusts; +using System; +using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.DataStructures; @@ -43,9 +44,19 @@ namespace CalamityMod.Tiles.Astral public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - r = Main.DiscoR / 255f * 0.5f; - g = 0.5f; - b = (255 - Main.DiscoR) / 255f * 0.5f; + float brightness = 0.9f; + brightness += 0.2f; + brightness = MathHelper.Clamp(brightness, 0.5f, 0.9f); + Color orange = new Color(237, 93, 83); + Color cyan = new Color(66, 189, 181); + Color value = Color.Lerp(orange, cyan, (MathF.Sin(j / 30f + Main.GameUpdateCount * 0.017f + -i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(orange, cyan, (MathF.Sin((-j - 100) / 40f + Main.GameUpdateCount * 0.014f + i / 20f) + 1f) / 2f); + r = (value.R + value1.R) / 600f; + g = (value.G + value1.G) / 600f; + b = (value.B + value1.B) / 600f; + r *= brightness; + g *= brightness; + b *= brightness; } } } diff --git a/Tiles/Ores/AstralOre.cs b/Tiles/Ores/AstralOre.cs index 85642511f6..78c65587a8 100644 --- a/Tiles/Ores/AstralOre.cs +++ b/Tiles/Ores/AstralOre.cs @@ -75,15 +75,16 @@ namespace CalamityMod.Tiles.Ores public override void ModifyLight(int i, int j, ref float r, ref float g, ref float b) { - float brightness = 0.7f; - brightness *= (float)MathF.Sin(-j / 40f + Main.GameUpdateCount * 0.007f); - brightness *= (float)MathF.Sin(-i / 40f + Main.GameUpdateCount * 0.005f); - brightness *= (float)MathF.Sin(-j / 40f + Main.GameUpdateCount * 0.006f); - brightness *= (float)MathF.Sin(-i / 40f + Main.GameUpdateCount * 0.009f); + float brightness = 0.9f; brightness += 0.5f; - r = Main.DiscoR / 255f * 0.5f; - g = 0.5f; - b = (255 - Main.DiscoR) / 255f * 0.5f; + brightness = MathHelper.Clamp(brightness, 0.5f, 0.9f); + Color orange = new Color(237, 93, 83); + Color cyan = new Color(66, 189, 181); + Color value = Color.Lerp(orange, cyan, (MathF.Sin(-j / 30f + Main.GameUpdateCount * 0.017f + i / 40f) + 1f) / 2f); + Color value1 = Color.Lerp(orange, cyan, (MathF.Sin((j - 100) / 40f + Main.GameUpdateCount * 0.014f + -i / 20f) + 1f) / 2f); + r = (value.R + value1.R) / 600f; + g = (value.G + value1.G) / 600f; + b = (value.B + value1.B) / 600f; r *= brightness; g *= brightness; b *= brightness; diff --git a/Walls/AstralGrassWall.cs b/Walls/AstralGrassWall.cs index 9c9d47d456..81d9371fcf 100644 --- a/Walls/AstralGrassWall.cs +++ b/Walls/AstralGrassWall.cs @@ -1,11 +1,15 @@  using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using System; +using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Walls { public class AstralGrassWall : ModWall { + public static Vector2 TileAdj => (Lighting.Mode == Terraria.Graphics.Light.LightMode.Retro || Lighting.Mode == Terraria.Graphics.Light.LightMode.Trippy) ? Vector2.Zero : Vector2.One * 12; /*public override bool Autoload(ref string name, ref string texture) { mod.AddWall("AstralGrassWallUnsafe", this, texture); @@ -22,6 +26,20 @@ namespace CalamityMod.Walls AddMapEntry(new Color(60, 48, 64)); } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) + { + if (i > Main.screenPosition.X / 16 && i < Main.screenPosition.X / 16 + Main.screenWidth / 16 && j > Main.screenPosition.Y / 16 && j < Main.screenPosition.Y / 16 + Main.screenHeight / 16) + { + Texture2D tex = ModContent.Request("CalamityMod/Walls/AstralGrassWallLeaves").Value; + var rand = new Random(i + (j * 100000)); + + float offset = i * j % 6.28f + (float)rand.NextDouble() / 8f; + float sin = (float)Math.Sin(Main.GameUpdateCount / 45f + offset); + + spriteBatch.Draw(tex, (new Vector2(i + 0.5f, j + 0.5f) + TileAdj) * 16 + new Vector2(1, 0.5f) * sin * 2.2f - Main.screenPosition, + new Rectangle(rand.Next(4) * 26, 0, 24, 24), Lighting.GetColor(i, j), offset + sin * 0.09f, new Vector2(12, 12), 1 + sin / 14f, 0, 0); + } + } public override void NumDust(int i, int j, bool fail, ref int num) => num = fail ? 1 : 3; } diff --git a/Walls/AstralGrassWall.png b/Walls/AstralGrassWall.png index d673f1974c..5e59d53fcc 100644 Binary files a/Walls/AstralGrassWall.png and b/Walls/AstralGrassWall.png differ diff --git a/Walls/AstralGrassWallLeaves.png b/Walls/AstralGrassWallLeaves.png new file mode 100644 index 0000000000..893e4c61d1 Binary files /dev/null and b/Walls/AstralGrassWallLeaves.png differ diff --git a/World/AstralBiome.cs b/World/AstralBiome.cs index 8010974902..5ef2b1d868 100644 --- a/World/AstralBiome.cs +++ b/World/AstralBiome.cs @@ -569,7 +569,7 @@ namespace CalamityMod.World WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1); break; - case WallID.LivingWood: + case WallID.LivingWoodUnsafe: Main.tile[x, y].WallType = (ushort)ModContent.WallType(); WorldGen.SquareWallFrame(x, y, true); NetMessage.SendTileSquare(-1, x, y, 1);