diff --git a/Assets/Masks/RingGlow.png b/Assets/Masks/RingGlow.png new file mode 100644 index 000000000..8833cf304 Binary files /dev/null and b/Assets/Masks/RingGlow.png differ diff --git a/Assets/Masks/RingGlowInner.png b/Assets/Masks/RingGlowInner.png new file mode 100644 index 000000000..2e12b35e5 Binary files /dev/null and b/Assets/Masks/RingGlowInner.png differ diff --git a/Assets/Masks/RingGlowInnerTwo.png b/Assets/Masks/RingGlowInnerTwo.png new file mode 100644 index 000000000..a1df4ff04 Binary files /dev/null and b/Assets/Masks/RingGlowInnerTwo.png differ diff --git a/Assets/Misc/AuroraWater.png b/Assets/Misc/AuroraWater.png index 7c26549d8..8d9e38e7b 100644 Binary files a/Assets/Misc/AuroraWater.png and b/Assets/Misc/AuroraWater.png differ diff --git a/Content/Bosses/SquidBoss/Misc.AuroraWaterMetaballs.cs b/Content/Bosses/SquidBoss/Misc.AuroraWaterMetaballs.cs index 438e6cbdb..2c5fc40fb 100644 --- a/Content/Bosses/SquidBoss/Misc.AuroraWaterMetaballs.cs +++ b/Content/Bosses/SquidBoss/Misc.AuroraWaterMetaballs.cs @@ -12,19 +12,13 @@ internal class AuroraWaterMetaballs : MetaballActor { public override bool Active => Main.LocalPlayer.InModBiome(ModContent.GetInstance()); - public override Color OutlineColor => new(255, 254, 255); + public override Color OutlineColor => new(255, 0, 0); public override void DrawShapes(SpriteBatch spriteBatch) { Texture2D tex = Assets.Items.Misc.MagmaGunProj.Value; - for (int k = 0; k < Main.maxNPCs; k++) - { - NPC NPC = Main.npc[k]; - - if (NPC.active && NPC.ModNPC is ArenaActor) - (NPC.ModNPC as ArenaActor).DrawWater(Main.spriteBatch); - } + ArenaActor.latestActor?.DrawWater(Main.spriteBatch); Effect borderNoise = ShaderLoader.GetShader("BorderNoise").Value; @@ -41,7 +35,7 @@ public override void DrawShapes(SpriteBatch spriteBatch) if (dust.active && (dust.type == ModContent.DustType() || dust.type == ModContent.DustType())) { borderNoise.Parameters["offset"].SetValue((float)Main.time / 1000f + dust.rotation); - spriteBatch.Draw(tex, (dust.position - Main.screenPosition) / 2, null, new Color(0.4f, 1, 1), 0f, Vector2.One * 256f, dust.scale * 0.05f, SpriteEffects.None, 0); + spriteBatch.Draw(tex, (dust.position - Main.screenPosition) / 2, null, new Color(0, 255, 0), 0f, Vector2.One * 256f, dust.scale * 0.05f, SpriteEffects.None, 0); } } @@ -50,7 +44,7 @@ public override void DrawShapes(SpriteBatch spriteBatch) Texture2D tex2 = Assets.Bosses.SquidBoss.AuroraWaterSplash.Value; var frame = new Rectangle(0, (int)(6 - proj.timeLeft / 40f * 6) * 106, 72, 106); - spriteBatch.Draw(tex2, (proj.Center - Main.screenPosition) / 2f, frame, new Color(0.4f, 1, 1), 0, new Vector2(36, 53), 0.5f, 0, 0); + spriteBatch.Draw(tex2, (proj.Center - Main.screenPosition) / 2f, frame, new Color(0, 255, 0), 0, new Vector2(36, 53), 0.5f, 0, 0); } spriteBatch.End(); @@ -87,21 +81,29 @@ public override bool PostDraw(SpriteBatch spriteBatch, Texture2D target) if (effect != null) { + Main.spriteBatch.End(); + Main.graphics.GraphicsDevice.SetRenderTarget(Main.screenTargetSwap); + effect.Parameters["uTime"].SetValue((float)Main.timeForVisualEffects * 0.02f); - effect.Parameters["power"].SetValue(0.01f); effect.Parameters["offset"].SetValue(new Vector2(Main.screenPosition.X / Main.screenWidth * -0.5f, Main.screenPosition.Y / Main.screenHeight * -0.5f)); effect.Parameters["sampleTexture"].SetValue(AuroraWaterSystem.auroraBackTarget.RenderTarget); effect.Parameters["uImageSize1"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight)); - effect.Parameters["speed"].SetValue(50f); effect.Parameters["lightTexture"].SetValue(LightingBuffer.screenLightingTarget.RenderTarget); + effect.Parameters["gameTexture"].SetValue(Main.screenTarget); + effect.Parameters["transform"].SetValue(Matrix.Invert(Main.GameViewMatrix.TransformationMatrix)); - Main.spriteBatch.End(); - Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, Main.Rasterizer, effect, Main.GameViewMatrix.TransformationMatrix); + var inv = Matrix.Invert(Main.GameViewMatrix.TransformationMatrix); + + Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, RasterizerState.CullNone, effect, Matrix.Identity); - Main.spriteBatch.Draw(target, Vector2.Zero, null, Color.Red * 0.4f, 0, Vector2.Zero, 2, 0, 0); + Main.spriteBatch.Draw(target, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 2, 0, 0); Main.spriteBatch.End(); - Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, Main.Rasterizer, default, Main.GameViewMatrix.TransformationMatrix); + + Main.graphics.GraphicsDevice.SetRenderTarget(Main.screenTarget); + + Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, RasterizerState.CullNone, default, Matrix.Identity); + Main.spriteBatch.Draw(Main.screenTargetSwap, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, 0, 0); } return false; diff --git a/Content/Bosses/SquidBoss/NPCs.ArenaActor.cs b/Content/Bosses/SquidBoss/NPCs.ArenaActor.cs index 17e427350..306a69317 100644 --- a/Content/Bosses/SquidBoss/NPCs.ArenaActor.cs +++ b/Content/Bosses/SquidBoss/NPCs.ArenaActor.cs @@ -27,6 +27,8 @@ class ArenaActor : ModNPC private static VertexPositionColorTexture[] verticies; private static VertexBuffer buffer; + public static ArenaActor latestActor; + public ref float WaterLevel => ref NPC.ai[0]; public ref float VisualTimerA => ref NPC.ai[1]; public ref float VisualTimerB => ref NPC.ai[2]; @@ -106,6 +108,8 @@ private void DoParticleUpdates() public override void AI() { + latestActor = this; + VisualTimerA += 0.04f; //used as timers for visuals VisualTimerB += 0.01f; @@ -316,7 +320,7 @@ public void DrawWater(SpriteBatch spriteBatch) Vector2 pos = NPC.Center + new Vector2(-840, 30 * 16) + new Vector2(0, -tex.Height) - Main.screenPosition; var source = new Rectangle(0, tex.Height - (int)WaterLevel + 5 * 16, tex.Width, (int)WaterLevel - 5 * 16); - spriteBatch.Draw(tex, (pos + source.TopLeft()) * 0.5f, source, new Color(0.4f, 1, 1), 0, default, 0.5f, 0, 0); + spriteBatch.Draw(tex, (pos + source.TopLeft()) * 0.5f, source, new Color(0, 255, 0), 0, default, 0.5f, 0, 0); DrawWaterfalls(spriteBatch); } diff --git a/Content/Bosses/SquidBoss/NPCs.IcePlatform.cs b/Content/Bosses/SquidBoss/NPCs.IcePlatform.cs index 60ef2c05e..eb8889796 100644 --- a/Content/Bosses/SquidBoss/NPCs.IcePlatform.cs +++ b/Content/Bosses/SquidBoss/NPCs.IcePlatform.cs @@ -47,7 +47,7 @@ public override void SafeAI() if (Main.npc.Any(n => n.active && n.type == ModContent.NPCType())) { - var actor = Main.npc.FirstOrDefault(n => n.active && n.type == ModContent.NPCType()).ModNPC as ArenaActor; + ArenaActor actor = ArenaActor.latestActor; if (NPC.position.Y >= HomeYPosition) { diff --git a/Content/Bosses/SquidBoss/NPCs.SquidBoss.Attacks.cs b/Content/Bosses/SquidBoss/NPCs.SquidBoss.Attacks.cs index 1d6700030..9e9317e63 100644 --- a/Content/Bosses/SquidBoss/NPCs.SquidBoss.Attacks.cs +++ b/Content/Bosses/SquidBoss/NPCs.SquidBoss.Attacks.cs @@ -1052,7 +1052,7 @@ private void TentacleSpike2() { RandomizeTarget(); - tentacles[k].Center = new Vector2(Main.npc.FirstOrDefault(n => n.active && n.ModNPC is ArenaActor).Center.X + (k % 2 == 0 ? -500 : 500), NPC.Center.Y + Main.rand.Next(-200, 200)); + tentacles[k].Center = new Vector2(ArenaActor.latestActor.NPC.Center.X + (k % 2 == 0 ? -500 : 500), NPC.Center.Y + Main.rand.Next(-200, 200)); tentacle.basePoint = tentacles[k].Center; tentacle.movementTarget = Main.player[NPC.target].Center; diff --git a/Content/Bosses/SquidBoss/NPCs.SquidBoss.cs b/Content/Bosses/SquidBoss/NPCs.SquidBoss.cs index 972c28c5a..cc9da770c 100644 --- a/Content/Bosses/SquidBoss/NPCs.SquidBoss.cs +++ b/Content/Bosses/SquidBoss/NPCs.SquidBoss.cs @@ -483,7 +483,7 @@ public override void AI() Animate(12, 0, 8); if (arenaActor is null || !arenaActor.active) - arenaActor = Main.npc.FirstOrDefault(n => n.active && n.ModNPC is ArenaActor); + arenaActor = ArenaActor.latestActor.NPC; if (Phase > (int)AIStates.SpawnAnimation) FindEssentialNPCs(); @@ -840,7 +840,7 @@ public override void AI() GlobalTimer++; if (GlobalTimer % 6 == 0) - Main.npc.FirstOrDefault(n => n.active && n.ModNPC is ArenaActor).ai[0]++; //rising water + ArenaActor.latestActor.WaterLevel++; //rising water AttackTimer++; diff --git a/Content/CustomHooks/Mechanics.PassiveLight.cs b/Content/CustomHooks/Mechanics.PassiveLight.cs index 06546fe3e..3fc1955aa 100644 --- a/Content/CustomHooks/Mechanics.PassiveLight.cs +++ b/Content/CustomHooks/Mechanics.PassiveLight.cs @@ -1,4 +1,5 @@ using StarlightRiver.Content.Biomes; +using StarlightRiver.Content.Bosses.SquidBoss; using StarlightRiver.Content.Events; using System.Collections.Generic; using Terraria.ID; @@ -93,6 +94,15 @@ public override void PostUpdateEverything() squidDomeRect.Y += 35; squidDomeRect.Height = 76; } + + if (ArenaActor.latestActor?.WaterLevel > 1100) + { + squidDomeRect.Height = (int)(76 - (ArenaActor.latestActor.WaterLevel - 1100) / 16); + } + else + { + squidDomeRect.Height = 76; + } } } } \ No newline at end of file diff --git a/Content/CustomHooks/Visuals.DrawUnderCathedralWater.cs b/Content/CustomHooks/Visuals.DrawUnderCathedralWater.cs index 88618e862..df34649ad 100644 --- a/Content/CustomHooks/Visuals.DrawUnderCathedralWater.cs +++ b/Content/CustomHooks/Visuals.DrawUnderCathedralWater.cs @@ -43,12 +43,12 @@ public static void DrawWater() Main.spriteBatch.End(); Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, Main.Rasterizer, default, Main.GameViewMatrix.TransformationMatrix); - NPC NPC = Main.npc.FirstOrDefault(n => n.active && n.ModNPC is ArenaActor); + NPC npc = ArenaActor.latestActor?.NPC; - if (NPC != null && NPC.active) + if (npc != null && npc.active) { if (ReflectionTarget.canUseTarget || !ModContent.GetInstance().ReflectionConfig.ReflectionsOn) - (NPC.ModNPC as ArenaActor).DrawBigWindow(Main.spriteBatch); + (npc.ModNPC as ArenaActor).DrawBigWindow(Main.spriteBatch); int boss = -1; var drawCache = new List(); diff --git a/Content/Items/Permafrost/Accessories.SquidFins.cs b/Content/Items/Permafrost/Accessories.SquidFins.cs index c456dfa9e..223856350 100644 --- a/Content/Items/Permafrost/Accessories.SquidFins.cs +++ b/Content/Items/Permafrost/Accessories.SquidFins.cs @@ -28,7 +28,7 @@ public override void SafeUpdateEquip(Player player) { bool canSwim = player.grapCount <= 0 && player.wet && !player.mount.Active; player.GetModPlayer().ShouldSwim = canSwim; - player.GetModPlayer().SwimSpeed = 1.33f + player.moveSpeed * 1.33f; + player.GetModPlayer().SwimSpeed += 3f + player.moveSpeed * 1.33f; } private void DrawSquidFins(ref PlayerDrawSet drawInfo) diff --git a/Content/NPCs/Permafrost/WaterCube.cs b/Content/NPCs/Permafrost/WaterCube.cs index f279c183e..7ad75056e 100644 --- a/Content/NPCs/Permafrost/WaterCube.cs +++ b/Content/NPCs/Permafrost/WaterCube.cs @@ -28,6 +28,8 @@ public override void AI() { AuroraWaterSystem.visCounter = 30; NPC.velocity.X = 1; + + Lighting.AddLight(NPC.Center, new Vector3(0.4f, 0.8f, 1f)); } public override bool CanHitPlayer(Player target, ref int cooldownSlot) @@ -49,7 +51,7 @@ public void DrawToTarget(SpriteBatch spriteBatch) Vector2 pos = (NPC.position - Main.screenPosition) / 2f; var target = new Rectangle((int)pos.X, (int)pos.Y, NPC.width / 2, NPC.height / 2); - spriteBatch.Draw(tex, target, Color.Red); + spriteBatch.Draw(tex, target, Color.Lime); } } } \ No newline at end of file diff --git a/Core/Systems/AuroraWaterSystem/AuroraWaterSystem.cs b/Core/Systems/AuroraWaterSystem/AuroraWaterSystem.cs index 98ce5d897..6213ecb7f 100644 --- a/Core/Systems/AuroraWaterSystem/AuroraWaterSystem.cs +++ b/Core/Systems/AuroraWaterSystem/AuroraWaterSystem.cs @@ -2,11 +2,15 @@ using StarlightRiver.Content.Dusts; using StarlightRiver.Content.NPCs.Permafrost; using StarlightRiver.Core.Loaders; +using StarlightRiver.Core.Systems.LightingSystem; using StarlightRiver.Core.Systems.MetaballSystem; using StarlightRiver.Core.Systems.ScreenTargetSystem; using System; +using System.Collections.Generic; using System.Linq; +using Terraria.ID; using Terraria.ModLoader.IO; +using Terraria.WorldBuilding; namespace StarlightRiver.Core.Systems.AuroraWaterSystem @@ -34,6 +38,21 @@ public int AuroraWaterFrameY } } + class AuroraRipple + { + public Vector2 pos; + public float scale; + public float speed; + public float prog; + + public AuroraRipple(Vector2 pos, float scale, float speed) + { + this.pos = pos; + this.scale = scale; + this.speed = speed; + } + } + class AuroraWaterSystem : ModSystem { public static int visCounter = 0; @@ -44,6 +63,8 @@ class AuroraWaterSystem : ModSystem public static bool failedLoad = false; + public static List ripplePoints = new(); + public float Priority => 1; public override void Load() @@ -115,6 +136,7 @@ private static void DrawAuroraTarget(SpriteBatch sb) private static void DrawAuroraBackTarget(SpriteBatch sb) { Asset asset = Assets.Misc.AuroraWaterMap; + Asset asset2 = Assets.Noise.SwirlyNoiseLooping; if (asset.IsLoaded) { @@ -124,6 +146,9 @@ private static void DrawAuroraBackTarget(SpriteBatch sb) Main.graphics.GraphicsDevice.Clear(Color.Transparent); Texture2D tex = asset.Value; + Texture2D tex2 = asset2.Value; + Texture2D tex3 = Assets.Masks.Glow.Value; + Texture2D rippleTex = Assets.Masks.RingGlowInnerTwo.Value; Vector2 layer1Pivot = Main.GameUpdateCount * new Vector2(-0.55f, 0.3f); Vector2 layer2Pivot = Main.GameUpdateCount * new Vector2(0.75f, -0.4f); @@ -134,7 +159,7 @@ private static void DrawAuroraBackTarget(SpriteBatch sb) (int)(Main.screenPosition.Y + layer1Pivot.Y) % tex.Height, Main.screenWidth, Main.screenHeight), - Color.White * 0.7f); + Color.Red * 0.7f); sb.Draw(tex, Vector2.Zero, new Rectangle( @@ -142,13 +167,74 @@ private static void DrawAuroraBackTarget(SpriteBatch sb) (int)(Main.screenPosition.Y + layer2Pivot.Y) % tex.Height, Main.screenWidth, Main.screenHeight), - Color.White); + Color.Red); + + sb.Draw(tex2, + Vector2.Zero, + new Rectangle( + (int)(Main.screenPosition.X + layer1Pivot.X) % tex2.Width, + (int)(Main.screenPosition.Y + layer1Pivot.Y) % tex2.Height, + Main.screenWidth, + Main.screenHeight), + Color.Green * 0.7f); + sb.Draw(tex2, + Vector2.Zero, + new Rectangle( + (int)(Main.screenPosition.X + layer2Pivot.X) % tex2.Width, + (int)(Main.screenPosition.Y + layer2Pivot.Y) % tex2.Height, + Main.screenWidth, + Main.screenHeight), + Color.Green); + + sb.Draw(tex3, + Main.LocalPlayer.Center - Main.screenPosition, + null, + Color.Blue, 0, tex3.Size() / 2f, 3f, 0, 0); + + foreach (AuroraRipple ripple in ripplePoints) + { + Color col = Color.Lime * (1f - ripple.prog) * ripple.scale; + Color col2 = Color.Red * (1f - ripple.prog) * ripple.scale; + sb.Draw(rippleTex, ripple.pos - Main.screenPosition, null, col, 0, rippleTex.Size() / 2f, ripple.scale * ripple.prog, 0, 0); + sb.Draw(rippleTex, ripple.pos - Main.screenPosition, null, col2, 0, rippleTex.Size() / 2f, ripple.scale * ripple.prog, 0, 0); + } sb.End(); sb.Begin(); } } + public override void PostUpdateNPCs() + { + Rectangle rectangle = WorldUtils.ClampToWorld(new Rectangle((int)Main.screenPosition.X / 16, (int)Main.screenPosition.Y / 16, Main.screenWidth / 16, Main.screenHeight / 16)); + for (int k = rectangle.Left; k < rectangle.Right; k++) + { + for (int l = rectangle.Top; l < rectangle.Bottom; l++) + { + Tile tile = Main.tile[k, l]; + if (tile.Get().HasAuroraWater) + { + AuroraWaterSystem.visCounter = 30; + + if (l % 2 == 0 && k % 2 == 0 && !tile.IsSquareSolidTile()) + Lighting.AddLight(new Vector2(k, l) * 16, new Vector3(0.4f, 0.8f, 1f)); + } + } + } + + for (int k = 0; k < ripplePoints.Count; k++) + { + ripplePoints[k].prog += ripplePoints[k].speed; + } + + ripplePoints.RemoveAll(n => n.prog >= 1f); + } + + public static void AddRipple(Vector2 pos, float scale, float speed) + { + ripplePoints.Add(new(pos, scale, speed)); + } + private void DrawAuroraWater(On_Main.orig_DrawInfernoRings orig, Main self) { orig(self); @@ -286,20 +372,11 @@ public override unsafe void LoadWorldData(TagCompound tag) } } - class AuroraWaterGlobalTile : GlobalTile - { - public override void NearbyEffects(int i, int j, int type, bool closer) - { - if (Main.tile[i, j].Get().HasAuroraWater) - AuroraWaterSystem.visCounter = 30; - } - } - class AuroraWaterTileMetaballs : MetaballActor { public override bool Active => AuroraWaterSystem.Visible && !Main.LocalPlayer.InModBiome(ModContent.GetInstance()); - public override Color OutlineColor => new(255, 0, 255); + public override Color OutlineColor => new(255, 0, 0); public override void DrawShapes(SpriteBatch spriteBatch) { @@ -319,7 +396,7 @@ public override void DrawShapes(SpriteBatch spriteBatch) foreach (Dust dust in Main.dust) { if (dust.active && dust.type == ModContent.DustType()) - spriteBatch.Draw(tex, (dust.position - Main.screenPosition) / 2, null, Color.Red, 0f, Vector2.One * 256f, dust.scale * 0.05f, SpriteEffects.None, 0); + spriteBatch.Draw(tex, (dust.position - Main.screenPosition) / 2, null, Color.Lime, 0f, Vector2.One * 256f, dust.scale * 0.05f, SpriteEffects.None, 0); } spriteBatch.End(); @@ -336,27 +413,39 @@ public static void DrawSpecial() return; } - Effect shader = ShaderLoader.GetShader("AuroraWaterShader").Value; + Effect effect = ShaderLoader.GetShader("AuroraWaterShader").Value; - if (shader is null) + if (effect is null) { MetaballSystem.MetaballSystem.actorsSem.Release(); return; } - shader.Parameters["time"].SetValue(StarlightWorld.visualTimer); - shader.Parameters["screenSize"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight)); - shader.Parameters["offset"].SetValue(new Vector2(Main.screenPosition.X % Main.screenWidth / Main.screenWidth, Main.screenPosition.Y % Main.screenHeight / Main.screenHeight)); - shader.Parameters["sampleTexture2"].SetValue(AuroraWaterSystem.auroraBackTarget.RenderTarget); - Main.spriteBatch.End(); - Main.spriteBatch.Begin(default, BlendState.Additive, Main.DefaultSamplerState, default, Main.Rasterizer, shader, Main.GameViewMatrix.TransformationMatrix); + Main.graphics.GraphicsDevice.SetRenderTarget(Main.screenTargetSwap); + + effect.Parameters["uTime"].SetValue((float)Main.timeForVisualEffects * 0.02f); + effect.Parameters["offset"].SetValue(new Vector2(Main.screenPosition.X / Main.screenWidth * -0.5f, Main.screenPosition.Y / Main.screenHeight * -0.5f)); + effect.Parameters["sampleTexture"].SetValue(AuroraWaterSystem.auroraBackTarget.RenderTarget); + effect.Parameters["uImageSize1"].SetValue(new Vector2(Main.screenWidth, Main.screenHeight)); + //effect.Parameters["lightTexture"].SetValue(LightingBuffer.screenLightingTarget.RenderTarget); + effect.Parameters["gameTexture"].SetValue(Main.screenTarget); + effect.Parameters["transform"].SetValue(Matrix.Invert(Main.GameViewMatrix.TransformationMatrix)); + effect.Parameters["offset"].SetValue(new Vector2(Main.screenPosition.X % Main.screenWidth / Main.screenWidth, Main.screenPosition.Y % Main.screenHeight / Main.screenHeight)); + + var inv = Matrix.Invert(Main.GameViewMatrix.TransformationMatrix); + + Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, RasterizerState.CullNone, effect, Matrix.Identity); Texture2D target = MetaballSystem.MetaballSystem.actors.FirstOrDefault(n => n is AuroraWaterTileMetaballs).Target.RenderTarget; Main.spriteBatch.Draw(target, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 2, 0, 0); Main.spriteBatch.End(); - Main.spriteBatch.Begin(0, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + Main.graphics.GraphicsDevice.SetRenderTarget(Main.screenTarget); + + Main.spriteBatch.Begin(default, default, SamplerState.PointClamp, default, RasterizerState.CullNone, default, Matrix.Identity); + Main.spriteBatch.Draw(Main.screenTargetSwap, Vector2.Zero, null, Color.White, 0, Vector2.Zero, 1, 0, 0); MetaballSystem.MetaballSystem.actorsSem.Release(); } diff --git a/Core/Systems/AuroraWaterSystem/SwimPlayer.cs b/Core/Systems/AuroraWaterSystem/SwimPlayer.cs index 5d086a27f..5ce50dc95 100644 --- a/Core/Systems/AuroraWaterSystem/SwimPlayer.cs +++ b/Core/Systems/AuroraWaterSystem/SwimPlayer.cs @@ -11,7 +11,12 @@ class SwimPlayer : ModPlayer float targetRotation = 0; float realRotation = 0; float armRotation; + int emergeTime = 0; + float emergeRotatio = 0; + + int emergeBoostTime = 0; + Vector2 emergeBoostSpeed = default; public bool wasSwimming; @@ -51,6 +56,8 @@ class SwimPlayer : ModPlayer { if (!wasSwimming) { + AuroraWaterSystem.AddRipple(Player.Center, 1.5f, 0.03f); + SoundHelper.PlayPitched("Magic/WaterWoosh", 0.8f, 0, Player.Center); for (int k = 0; k < 20; k++) @@ -62,7 +69,6 @@ class SwimPlayer : ModPlayer } ShouldSwim = true; - SwimSpeed *= 0.7f; } } } @@ -71,11 +77,40 @@ public override void PreUpdate() { CheckAuroraSwimming(); + if (emergeBoostTime > 0) + { + // Special effects for when we re-enter out of an exit boost + if (ShouldSwim) + { + emergeBoostTime = 0; + Player.velocity = Vector2.Normalize(Player.velocity) * 0.5f; + + SoundHelper.PlayPitched("Magic/WaterWoosh", 1f, -0.3f, Player.Center); + + for (int k = 0; k < 20; k++) + { + Dust.NewDustPerfect(Player.Center, DustType(), -Vector2.Normalize(Player.velocity).RotatedByRandom(0.5f) * Main.rand.NextFloat(15), 0, new Color(200, 220, 255) * 0.4f, Main.rand.NextFloat(0.2f, 0.8f)); + } + } + else + { + // Makes the exit boost "flat" + emergeBoostTime--; + Player.velocity = emergeBoostSpeed * (0.1f + emergeBoostTime / 20f); + + for (int k = 0; k < 5; k++) + { + Dust.NewDustPerfect(Player.Center + Main.rand.NextVector2Circular(16, 16), DustType(), -Vector2.Normalize(Player.velocity).RotatedByRandom(0.5f) * Main.rand.NextFloat(5), 0, new Color(100, Main.rand.Next(150, 255), 255, 0), Main.rand.NextFloat(0.1f, 0.2f)); + } + } + } + if (emergeTime == 18) //reset jumps { Player.RefreshExtraJumps(); Player.rocketTime = Player.rocketTimeMax; Player.wingTime = Player.wingTimeMax; + emergeRotatio = realRotation; SoundHelper.PlayPitched("Magic/WaterWoosh", 0.8f, 0, Player.Center); @@ -84,6 +119,21 @@ public override void PreUpdate() Dust.NewDustPerfect(Player.Center, DustType(), Main.rand.NextVector2Circular(2, 2), 0, new Color(200, 220, 255) * 0.4f, Main.rand.NextFloat(0.2f, 0.8f)); } + if (boostCD > 20 && Player.velocity.Length() > 0) + { + SoundHelper.PlayPitched("SquidBoss/LightSplash", 1f, 0.2f, Player.Center); + + for (int k = 0; k < 20; k++) + { + Dust.NewDustPerfect(Player.Center, DustType(), Vector2.Normalize(Player.velocity).RotatedByRandom(0.5f) * Main.rand.NextFloat(15), 0, new Color(200, 220, 255) * 0.4f, Main.rand.NextFloat(0.2f, 0.8f)); + } + + emergeBoostTime = 20; + emergeBoostSpeed = Vector2.Normalize(Player.velocity) * 20; + + boostCD = 0; + } + wasSwimming = false; } @@ -91,7 +141,7 @@ public override void PreUpdate() { if (boostCD > 0) { - boostCD = 0; + //boostCD = 0; Player.UpdateRotation(0); } @@ -101,10 +151,6 @@ public override void PreUpdate() targetRotation = ShouldSwim ? Player.velocity.ToRotation() : 1.57f + 3.14f; - // Forces the rotation target to be upright if the player is emerging - if (emergeTime < 19) - targetRotation = -MathHelper.PiOver2; - realRotation %= 6.28f; //handles the rotation, ensures the Player wont randomly snap to rotation when entering/leaving swimming if (Math.Abs(targetRotation - realRotation) % 6.28f > 0.21f) @@ -124,6 +170,10 @@ static float Mod(float a, float b) realRotation = targetRotation; } + // Forces the rotation target to be upright if the player is emerging + if (emergeTime < 18) + realRotation = -MathHelper.PiOver2 + (emergeRotatio + MathHelper.PiOver2) * (emergeTime - 1) / 19f; + Player.fullRotationOrigin = Player.Size / 2; //so the Player rotates around their center... why is this not the default? Player.fullRotation = realRotation + MathHelper.PiOver2; @@ -154,53 +204,67 @@ static float Mod(float a, float b) Player.legFrame = new Rectangle(0, 56 * (int)(5 + Main.GameUpdateCount / 7 % 3), 40, 56); - float speed = 0.2f * SwimSpeed; + float speed = 0.02f * SwimSpeed; + Vector2 dir = Vector2.Zero; if (Player.controlRight) - Player.velocity.X += speed; //there should probably be a better way of doing this? + dir.X += 1; if (Player.controlLeft) - Player.velocity.X -= speed; + dir.X -= 1; if (Player.controlDown) - Player.velocity.Y += speed; + dir.Y += 1; if (Player.controlUp) - Player.velocity.Y -= speed; + dir.Y -= 1; + + if (dir.Length() > 0) + Player.velocity += Vector2.Normalize(dir) * speed; Player.gravity = 0; - Player.velocity *= 0.95f; + + float slow = Player.velocity.Length() > SwimSpeed ? 0.5f : 0.95f; + Player.velocity *= slow; + + if (Main.GameUpdateCount % 10 == 0) + AuroraWaterSystem.AddRipple(Player.Center, 0.5f + Player.velocity.Length() * 0.05f, 0.02f); if (Player.controlJump && boostCD <= 0) { - SoundHelper.PlayPitched("SquidBoss/MagicSplash", 1f, -0.5f, Player.Center); - SoundHelper.PlayPitched("SquidBoss/MagicSplash", 1f, 0f, Player.Center); + SoundHelper.PlayPitched("SquidBoss/LightSplash", Main.rand.NextFloat(0.5f, 0.8f), Main.rand.NextFloat(-0.9f, -0.6f), Player.Center); + SoundHelper.PlayPitched("Magic/WaterWoosh", Main.rand.NextFloat(0.3f, 0.6f), Main.rand.NextFloat(-0.5f, -0.2f), Player.Center); + AuroraWaterSystem.AddRipple(Player.Center, 1.5f, 0.03f); boostCD = 60; } - if (boostCD > 40) + if (boostCD > 20) { - float timer = (boostCD - 40) / 20f; - float angle = timer * 6.28f; - Vector2 vel = -Player.velocity * 0f; + float timer = (boostCD - 20) / 40f; + float angle = timer * 6.28f * 2f; + Vector2 vel = Vector2.One.RotatedByRandom(6.28f) * Main.rand.NextFloat(0.15f); Player.UpdateRotation(angle); for (int k = 0; k < 2; k++) { float prog = k / 2f; var off = new Vector2((float)Math.Cos(angle + 1 / 20f * 6.28f * prog) * 18, (float)Math.Sin(angle + 1 / 20f * 6.28f * prog) * 4); + Color color = new Color(timer, 1 - timer, 0.5f + 0.5f * MathF.Sin(timer * 3.14f), 0) * MathF.Sin(timer * 3.14f) * 0.3f; - var l = Dust.NewDustPerfect(Player.Center + Player.velocity * prog + off.RotatedBy(Player.fullRotation), DustType(), vel, 0, new Color(1 - timer, timer, 1), Main.rand.NextFloat(0.4f, 0.7f)); - var r = Dust.NewDustPerfect(Player.Center + Player.velocity * prog - off.RotatedBy(Player.fullRotation), DustType(), vel, 0, new Color(1 - timer, timer, 1), Main.rand.NextFloat(0.4f, 0.7f)); + var l = Dust.NewDustPerfect(Player.Center + Player.velocity * prog + off.RotatedBy(Player.fullRotation), DustType(), vel, 0, color, Main.rand.NextFloat(0.1f, 0.23f)); + var r = Dust.NewDustPerfect(Player.Center + Player.velocity * prog - off.RotatedBy(Player.fullRotation), DustType(), vel, 0, color, Main.rand.NextFloat(0.1f, 0.23f)); l.noGravity = true; r.noGravity = true; } + } + if (boostCD > 40) + { if (Player.velocity == Vector2.Zero) Player.velocity = new Vector2(0, -0.01f); - Player.velocity += Vector2.Normalize(Player.velocity) * 0.8f * SwimSpeed; + Player.velocity += Vector2.Normalize(Player.velocity) * 0.08f * SwimSpeed; Player.AddBuff(Terraria.ID.BuffID.Cursed, 1, true); } else @@ -231,7 +295,7 @@ public override void PostUpdate() public override void ResetEffects() { ShouldSwim = false; - SwimSpeed = 1f; + SwimSpeed = 10f; } } } \ No newline at end of file diff --git a/Effects/Source/AuroraWaterShader.fx b/Effects/Source/AuroraWaterShader.fx index 8b2cc98a1..aca3f0e1c 100644 --- a/Effects/Source/AuroraWaterShader.fx +++ b/Effects/Source/AuroraWaterShader.fx @@ -1,8 +1,10 @@ #include "Common.fxh" -float time; -float2 screenSize; -float2 offset; +sampler uImage0 : register(s0); +float uTime; +float2 uImageSize0; +float2 uImageSize1; +float4x4 transform; texture sampleTexture; sampler2D samplerTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; @@ -10,24 +12,63 @@ sampler2D samplerTex = sampler_state { texture = ; magfilter = LI texture sampleTexture2; sampler2D samplerTex2 = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; -float4 PixelShaderFunction(float4 screenSpace : TEXCOORD0) : COLOR0 -{ - float2 st = screenSpace.xy; - float2 off = float2(sin(time + st.y * 200.0 + offset.y * 100.0), sin(time + st.x * 200.0 + offset.x * 100.0)) / screenSize; +texture gameTexture; +sampler2D gameTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = clamp; AddressV = clamp; }; - float map = tex2D(samplerTex2, st * 2 + off).r; - float4 color = tex2D(samplerTex, st + off); +float2 offset; - float progress = (st.x + st.y) * 10.0; +float4 GetRainbow(float2 coords) +{ + float progress = (coords.x + coords.y) * 10.0; - float r = 40.0 * (1.0 + sin(time + progress * 0.2)); - float g = 46.0 * (1.0 + sin(HALF_PI + time + progress)); + float r = 40.0 * (1.0 + sin(uTime + progress * 0.2)); + float g = 46.0 * (1.0 + sin(HALF_PI + uTime + progress)); float b = 72.0; + + return float4(r, g, b, 0.0) * 0.005; +} - float3 colorB = float3(r, g, b); - float3 color2 = colorB * 0.015 * map * (color.r + color.b * 4.0); +float4 PixelShaderFunction(float4 screenSpace : TEXCOORD0) : COLOR0 +{ + float2 coords = screenSpace.xy; + float2 off = float2(sin(uTime + coords.y * 200.0 + offset.y * 100.0), sin(uTime + coords.x * 200.0 + offset.x * 100.0)) / uImageSize1; + + float2 originalCoords = coords; + + coords += off; + + float2 pixel = coords * uImageSize1 * 2.0; + coords = mul(float4(pixel, 0.0, 1.0), transform).xy / (uImageSize1 * 2.0); + + float2 pixCoord = coords - coords % (1.0 / uImageSize1) + float2(1.0 / uImageSize1); + + float4 mapSample = tex2D(samplerTex, coords * 2.0); + float swirl = sin((mapSample.g + uTime * 0.3) * 6.28); + + float4 light = GetRainbow(coords); + + float2 underCoord = coords * 2.0 + (swirl) * 0.005 * tex2D(uImage0, coords).a; + float2 pixUnderCoord = underCoord - underCoord % (2.0 / uImageSize1); + + float4 distortLight = GetRainbow(pixUnderCoord); + float shapeMask = tex2D(uImage0, coords).a; + + float lum = ((light.r + light.g + light.b) / 3.0); + + float caustics = tex2D(samplerTex, pixUnderCoord).r; + caustics = max(0.0, caustics - 0.1); + float speculars = tex2D(uImage0, pixCoord).g * 0.4 * (caustics + pow(caustics, 3.0) * 1.2 * lum); + speculars += tex2D(uImage0, coords).r * (0.5 + light * 0.5); + + float bright = pow(speculars, 6.0) * 200.0 * pow(lum, 2.0); + float4 color = distortLight * (pow(speculars, 2.0) * 3.0 + bright); + color.a = shapeMask; + + float2 originalUnderCoord = originalCoords * 2.0 + (swirl) * 0.005 * tex2D(uImage0, coords).a * (1.0 - mapSample.b); + float4 underColor = tex2D(gameTex, originalUnderCoord); + underColor += shapeMask * distortLight * distortLight * (1.0 - abs(swirl)); - return float4(color2, color.a) * 0.5; + return underColor + color; } technique Technique1 diff --git a/Effects/Source/Waves.fx b/Effects/Source/Waves.fx index 78d83a2bd..803b54cc6 100644 --- a/Effects/Source/Waves.fx +++ b/Effects/Source/Waves.fx @@ -1,20 +1,8 @@ sampler uImage0 : register(s0); -sampler uImage1 : register(s1); -sampler uImage2 : register(s2); -float3 uColor; -float3 uSecondaryColor; -float uOpacity; -float uSaturation; -float uRotation; float uTime; -float4 uSourceRect; -float2 uWorldPosition; -float uDirection; -float3 uLightSource; float2 uImageSize0; float2 uImageSize1; -float power; -float speed; +float4x4 transform; texture sampleTexture; sampler2D samplerTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; @@ -22,22 +10,53 @@ sampler2D samplerTex = sampler_state { texture = ; magfilter = LI texture lightTexture; sampler2D lightTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = wrap; AddressV = wrap; }; +texture gameTexture; +sampler2D gameTex = sampler_state { texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter = LINEAR; AddressU = clamp; AddressV = clamp; }; + float2 offset; float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0 -{ - float4 color = tex2D(uImage0, coords).a * tex2D(uImage0, coords).r * tex2D(lightTex, coords * 2.0); - float map = tex2D(samplerTex, coords * 2).r; - float map2 = map * map * map; - float bright = min((color.r + color.g + color.b) * 2.5, 0.005); +{ + float2 originalCoords = coords; + + float2 pixel = coords * uImageSize1 * 2.0; + coords = mul(float4(pixel, 0.0, 1.0), transform).xy / (uImageSize1 * 2.0); + + float2 pixCoord = coords - coords % (1.0 / uImageSize1) + float2(1.0 / uImageSize1); + + float4 mapSample = tex2D(samplerTex, coords * 2.0); + float swirl = sin((mapSample.g + uTime * 0.3) * 6.28); + + float4 light = tex2D(lightTex, coords * 2.0); + + float2 underCoord = coords * 2.0 + (swirl) * 0.005 * tex2D(uImage0, coords).a; + float2 pixUnderCoord = underCoord - underCoord % (2.0 / uImageSize1); + + float4 distortLight = tex2D(lightTex, pixUnderCoord); + float shapeMask = tex2D(uImage0, coords).a; + + float lum = ((light.r + light.g + light.b) / 3.0); + + float caustics = tex2D(samplerTex, pixUnderCoord).r; + caustics = max(0.0, caustics - 0.1); + float speculars = tex2D(uImage0, pixCoord).g * 0.4 * (caustics + pow(caustics, 3.0) * 1.2 * lum); + speculars += tex2D(uImage0, coords).r * (0.5 + light * 0.5); + + float bright = pow(speculars, 6.0) * 200.0 * pow(lum, 2.0); + float4 color = distortLight * (pow(speculars, 2.0) * 3.0 + bright); + color.a = shapeMask; + + float2 originalUnderCoord = originalCoords * 2.0 + (swirl) * 0.005 * tex2D(uImage0, coords).a; + float4 underColor = tex2D(gameTex, originalUnderCoord); + underColor += shapeMask * distortLight * distortLight * (1.0 - abs(swirl)); - return float4(color.xyz * map * 3.0, color.a * map); + return underColor + color; } technique Technique1 { pass Pass1 { - PixelShader = compile ps_2_0 PixelShaderFunction(); + PixelShader = compile ps_3_0 PixelShaderFunction(); } } \ No newline at end of file