diff --git a/Tiles/SunkenSea/EutrophicGlass.cs b/Tiles/SunkenSea/EutrophicGlass.cs index 77f47816d1..ebde80d594 100644 --- a/Tiles/SunkenSea/EutrophicGlass.cs +++ b/Tiles/SunkenSea/EutrophicGlass.cs @@ -1,4 +1,6 @@ -using CalamityMod.Systems; +using System; +using CalamityMod.Systems; +using Microsoft.CodeAnalysis.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -40,12 +42,22 @@ namespace CalamityMod.Tiles.SunkenSea num = fail ? 1 : 3; } + private static float GetFade1(int i, int j) + { + return (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.2f) + 1f) / 2f; + } + + private static float GetFade2(int i, int j) + { + return (MathF.Sin(Main.GlobalTimeWrappedHourly * 0.1f + i * 0.08f - j * 0.05f) + 1f) / 2f; + } + public override void PostDraw(int i, int j, SpriteBatch spriteBatch) { if (Main.tile[i, j].IsTileActuallyInvisible()) return; - float transparency = 0.6f; + float transparency = 0.4f; // Must be set here TileID.Sets.DrawsWalls[Type] = true; @@ -62,6 +74,41 @@ namespace CalamityMod.Tiles.SunkenSea Color color = Lighting.GetColor(i, j) * transparency; TileFramingSystem.SlopedGlowmask(in tile, i, j, tex, frame, CalamityUtils.ApplyPaint(Main.tile[i, j].TileColor, color, false), default); + + //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's + + Vector2 offScreen = Main.drawToScreen ? Vector2.Zero : new Vector2(Main.offScreenRange); + Vector2 position = new Vector2(i * 16, j * 16) - Main.screenPosition + offScreen; + Texture2D GlintTex = ModContent.Request(Texture + "_Glint").Value; + + Vector2 glintDir = new Vector2(1f, 1f); + glintDir.Normalize(); + + Vector2 screenPos = position; + + float projection = Vector2.Dot(screenPos, glintDir); + + // this sets the length between the glints diagonally + float screenDiagonalLength = Vector2.Dot(new Vector2(Main.screenWidth, Main.screenHeight), glintDir); + float[] beamCenters = new float[] + { + screenDiagonalLength * 0.53f, // upper glint + screenDiagonalLength * 0.63f, // middle glint + screenDiagonalLength * 0.73f // lower glint + }; + + float stripeWidth = 100f; + + foreach (float bc in beamCenters) + { + float dist = Math.Abs(projection - bc); + float strength = MathHelper.Clamp(1f - dist / stripeWidth, 0f, 1f); + + if (strength > 0f) + { + spriteBatch.Draw(GlintTex, position, frame, (Lighting.GetColor(i, j) * 2 ) * (strength * 0.4f), 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); + } + } } public override bool TileFrame(int i, int j, ref bool resetFrame, ref bool noBreak) diff --git a/Tiles/SunkenSea/EutrophicGlass_Glint.png b/Tiles/SunkenSea/EutrophicGlass_Glint.png new file mode 100644 index 0000000000..3b890a78f2 Binary files /dev/null and b/Tiles/SunkenSea/EutrophicGlass_Glint.png differ diff --git a/Tiles/SunkenSea/MediumSeaPrismCrystal_Glint.png b/Tiles/SunkenSea/MediumSeaPrismCrystal_Glint.png new file mode 100644 index 0000000000..4667f80b89 Binary files /dev/null and b/Tiles/SunkenSea/MediumSeaPrismCrystal_Glint.png differ diff --git a/Tiles/SunkenSea/SeaPrism.cs b/Tiles/SunkenSea/SeaPrism.cs index d5622cf98d..22310dc258 100644 --- a/Tiles/SunkenSea/SeaPrism.cs +++ b/Tiles/SunkenSea/SeaPrism.cs @@ -107,7 +107,7 @@ namespace CalamityMod.Tiles.SunkenSea spriteBatch.Draw(tex1, position, sourceRect, Lighting.GetColor(i, j) * 1.5f * GetFade1(i, j)); spriteBatch.Draw(tex2, position, sourceRect, Lighting.GetColor(i, j) * 1.5f * GetFade2(i, j)); - //Not sure sure how everything below will run on stuff so we may need to kill this cool glint thing I did + //IF this glint effect below runs poorly on lower end PC's we should keep it as a setting for those with good PC's Texture2D GlintTex = ModContent.Request("CalamityMod/Tiles/SunkenSea/SeaPrism_GlintMask").Value; diff --git a/Tiles/SunkenSea/YellowCoral.png b/Tiles/SunkenSea/YellowCoral.png index ef005dc85b..7c2ad9d150 100644 Binary files a/Tiles/SunkenSea/YellowCoral.png and b/Tiles/SunkenSea/YellowCoral.png differ