From 16d6388778eb0a6615013767600fc8fc5e0836a3 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Sun, 28 Jun 2026 20:20:33 -0400 Subject: [PATCH 1/5] Miscellaneous pig trio fixes and changes * Divine Swine's Swinespeak sound should now properly end after it despawns upon granting Divine Meat * Divine Swine is now immune to all debuffs and resistant to all elemental typings * Fixed Horrible Hog despawning immediately on hit after being transformed from a Piggy --- NPCs/NormalNPCs/DivineSwine.cs | 28 +++++++++++-------- .../HorribleHog.AI.Transitionals.cs | 6 +--- NPCs/NormalNPCs/Piggy.cs | 13 +++------ NPCs/NormalNPCs/PiggyGold.cs | 9 ++++-- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/NPCs/NormalNPCs/DivineSwine.cs b/NPCs/NormalNPCs/DivineSwine.cs index 931bab8b93..8743051f3b 100644 --- a/NPCs/NormalNPCs/DivineSwine.cs +++ b/NPCs/NormalNPCs/DivineSwine.cs @@ -112,7 +112,9 @@ namespace CalamityMod.NPCs.NormalNPCs Main.npcFrameCount[Type] = 14; NPCID.Sets.CountsAsCritter[Type] = true; NPCID.Sets.CantTakeLunchMoney[Type] = true; - NPCID.Sets.NormalGoldCritterBestiaryPriority.Insert(NPCID.Sets.NormalGoldCritterBestiaryPriority.IndexOf(NPCID.GoldBunny) + 3, Type); + NPCID.Sets.NormalGoldCritterBestiaryPriority.Insert(NPCID.Sets.NormalGoldCritterBestiaryPriority.IndexOf(NPCID.GoldBunny) + 1, Type); + NPCID.Sets.ImmuneToAllBuffs[Type] = true; + NPCID.Sets.ShimmerImmunity[Type] = true; } public override void SetDefaults() @@ -129,9 +131,12 @@ namespace CalamityMod.NPCs.NormalNPCs NPC.DeathSound = SoundID.NPCDeath1; NPC.immortal = true; NPC.noGravity = true; - NPC.Calamity().VulnerableToHeat = true; - NPC.Calamity().VulnerableToCold = true; - NPC.Calamity().VulnerableToSickness = true; + + NPC.Calamity().VulnerableToCold = false; + NPC.Calamity().VulnerableToElectricity = false; + NPC.Calamity().VulnerableToHeat = false; + NPC.Calamity().VulnerableToSickness = false; + NPC.Calamity().VulnerableToWater = false; } public override void OnSpawn(IEntitySource source) @@ -290,14 +295,10 @@ namespace CalamityMod.NPCs.NormalNPCs SoundEngine.PlaySound(SoundID.Item29 with { Volume = 0.1f }, NPC.Center); SoundEngine.PlaySound(IdleSound, NPC.Center); - if (SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out var activeSound)) - activeSound.Stop(); + if (SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out ActiveSound swineSpeakInstance)) + swineSpeakInstance.Stop(); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.Transform(ModContent.NPCType()); - NPC.netUpdate = true; - } + NPC.Transform(ModContent.NPCType()); } } @@ -432,6 +433,9 @@ namespace CalamityMod.NPCs.NormalNPCs GeneralParticleHandler.SpawnParticle(Main.rand.NextBool() ? meatSparkle : meatLight, true, Enums.GeneralDrawLayer.AfterNPCs); } + if (SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out ActiveSound swineSpeakInstance)) + swineSpeakInstance.Stop(); + // Despawn immediately afterwards. NPC.checkDead(); NPC.active = false; @@ -465,6 +469,8 @@ namespace CalamityMod.NPCs.NormalNPCs SoundEngine.PlaySound(SoundID.Item29 with { Volume = 0.1f }, NPC.Center); SoundEngine.PlaySound(IdleSound, NPC.Center); + if (SoundEngine.TryGetActiveSound(SwineSpeakSoundSlot, out ActiveSound swineSpeakInstance)) + swineSpeakInstance.Stop(); NPC.checkDead(); NPC.active = false; diff --git a/NPCs/NormalNPCs/HorribleHog/HorribleHog.AI.Transitionals.cs b/NPCs/NormalNPCs/HorribleHog/HorribleHog.AI.Transitionals.cs index 5d8522b4fe..0dd70afbc7 100644 --- a/NPCs/NormalNPCs/HorribleHog/HorribleHog.AI.Transitionals.cs +++ b/NPCs/NormalNPCs/HorribleHog/HorribleHog.AI.Transitionals.cs @@ -104,11 +104,7 @@ namespace CalamityMod.NPCs.NormalNPCs.HorribleHog if (SoundEngine.TryGetActiveSound(DevilsTongueSlot, out var activeSound)) activeSound.Stop(); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.Transform(ModContent.NPCType()); - NPC.netUpdate = true; - } + NPC.Transform(ModContent.NPCType()); } Animate(IdleFrame, IdleFrame, 0, false, dynamicChanges: true); diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index 86fc4b4116..20f8127463 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -168,7 +168,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.velocity.X *= 0.9f; NPC.rotation = 0f; - if (!SoundEngine.TryGetActiveSound(NearbySoundSlot, out _)) + if (Timer < 2 && !SoundEngine.TryGetActiveSound(NearbySoundSlot, out _)) NearbySoundSlot = SoundEngine.PlaySound(DivineSwine_SwineSpeakLoopingSound, NPC.Center, NearbySoundCallbackMethod); float lightSpawnDistance = MathHelper.Lerp(52f, 84f, Timer / 180f); @@ -211,7 +211,7 @@ namespace CalamityMod.NPCs.NormalNPCs GeneralParticleHandler.SpawnParticle(feather, manualDrawLayerOverride: Enums.GeneralDrawLayer.BeforeNPCs); } - if (Timer >= 180f && Main.netMode != NetmodeID.MultiplayerClient) + if (Timer >= 180f) { CustomPulse lightRing = new(NPC.Center, Vector2.Zero, Color.White, "CalamityMod/Particles/BloomRing", Vector2.One, 0f, 0f, 2f, 75); GeneralParticleHandler.SpawnParticle(lightRing); @@ -232,7 +232,6 @@ namespace CalamityMod.NPCs.NormalNPCs activeSound.Stop(); NPC.Transform(ModContent.NPCType()); - NPC.netUpdate = true; } } @@ -240,7 +239,7 @@ namespace CalamityMod.NPCs.NormalNPCs { NPC.velocity.X *= 0.9f; NPC.rotation = 0f; - if (!SoundEngine.TryGetActiveSound(NearbySoundSlot, out _)) + if (Timer < 2 && !SoundEngine.TryGetActiveSound(NearbySoundSlot, out _)) NearbySoundSlot = SoundEngine.PlaySound(HorribleHog_DevilsTongueLoopingSound, NPC.Center, NearbySoundCallbackMethod); float smokeOpacity = Utils.GetLerpValue(0f, 45f, Timer, true); @@ -264,11 +263,7 @@ namespace CalamityMod.NPCs.NormalNPCs if (SoundEngine.TryGetActiveSound(NearbySoundSlot, out var activeSound)) activeSound.Stop(); - if (Main.netMode != NetmodeID.MultiplayerClient) - { - NPC.Transform(ModContent.NPCType()); - NPC.netUpdate = true; - } + NPC.Transform(ModContent.NPCType()); } } diff --git a/NPCs/NormalNPCs/PiggyGold.cs b/NPCs/NormalNPCs/PiggyGold.cs index de5acee1b0..5f6978d906 100644 --- a/NPCs/NormalNPCs/PiggyGold.cs +++ b/NPCs/NormalNPCs/PiggyGold.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using CalamityMod.Items.Critters; using CalamityMod.Items.Placeables.Banners; using Microsoft.Xna.Framework; +using Terraria; using Terraria.GameContent.Bestiary; using Terraria.ID; using Terraria.ModLoader; @@ -16,9 +17,13 @@ namespace CalamityMod.NPCs.NormalNPCs { public override void SetStaticDefaults() { + Main.npcFrameCount[Type] = 8; + Main.npcCatchable[Type] = true; + NPCID.Sets.CountsAsCritter[Type] = true; + NPCID.Sets.CantTakeLunchMoney[Type] = true; + NPCID.Sets.TakesDamageFromHostilesWithoutBeingFriendly[Type] = true; NPCID.Sets.GoldCrittersCollection.Add(Type); - NPCID.Sets.NormalGoldCritterBestiaryPriority.Insert(NPCID.Sets.NormalGoldCritterBestiaryPriority.IndexOf(NPCID.GoldBunny) + 2, Type); - base.SetStaticDefaults(); + NPCID.Sets.NormalGoldCritterBestiaryPriority.Insert(NPCID.Sets.NormalGoldCritterBestiaryPriority.IndexOf(ModContent.NPCType()) + 1, Type); } public override void SetDefaults() From 05f3812ac5e9e0913bb28ed3b710e5618a4f5563 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Mon, 29 Jun 2026 16:01:21 -0400 Subject: [PATCH 2/5] Providence star trails refactor * Completely redid the trails for Providence's HolyBurnOrb and HolyLight projectiles because they've been bringing in many reports of lag since the release of Hog Wild --- Effects/CalamityShaders.cs | 6 + Effects/ProvidenceHolyOrbTrailShader.fx | 68 ++++ Effects/ProvidenceHolyOrbTrailShader.xnb | Bin 0 -> 2444 bytes Projectiles/Boss/HolyBurnOrb.cs | 417 +++++++++++------------ Projectiles/Boss/HolyLight.cs | 151 ++++---- 5 files changed, 361 insertions(+), 281 deletions(-) create mode 100644 Effects/ProvidenceHolyOrbTrailShader.fx create mode 100644 Effects/ProvidenceHolyOrbTrailShader.xnb diff --git a/Effects/CalamityShaders.cs b/Effects/CalamityShaders.cs index e9ff7b8999..6c70e67afb 100644 --- a/Effects/CalamityShaders.cs +++ b/Effects/CalamityShaders.cs @@ -266,6 +266,9 @@ namespace CalamityMod.Effects // The swirling aura effect seen around Horrible Hog while its idling. internal static Asset HorribleHogAuraShader; + + // The shader effect for the primitive trails drawn for Providence's HolyBurnOrb/HolyLight projectiles. + internal static Asset ProvidenceHolyOrbTrailShader; #endregion #region Big E's Shaders @@ -537,6 +540,9 @@ namespace CalamityMod.Effects HorribleHogAuraShader = LoadShader("HorribleHogAuraShader"); RegisterMiscShader(HorribleHogAuraShader, "ScaryAuraPass", "HorribleHogAura"); + + ProvidenceHolyOrbTrailShader = LoadShader("ProvidenceHolyOrbTrailShader"); + RegisterMiscShader(ProvidenceHolyOrbTrailShader, "TrailPass", "ProvidenceHolyOrbTrail"); #endregion #region Loading Big E's Shaders diff --git a/Effects/ProvidenceHolyOrbTrailShader.fx b/Effects/ProvidenceHolyOrbTrailShader.fx new file mode 100644 index 0000000000..9f5c67d241 --- /dev/null +++ b/Effects/ProvidenceHolyOrbTrailShader.fx @@ -0,0 +1,68 @@ +// 29JUN2026: fryzahh +// Programmed to work under the use of SanePrimitiveRenderer. +// Never use this shader with PrimitveRenderer. + +sampler baseStreakTexture : register(s0); +sampler distortionTexture : register(s1); + +matrix uTransformMatrix; +float time; +float glowPower; +float pixelationFactor; + +struct VertexShaderInput +{ + float4 Position : POSITION0; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +struct VertexShaderOutput +{ + float4 Position : SV_POSITION; + float4 Color : COLOR0; + float2 TextureCoordinates : TEXCOORD0; +}; + +VertexShaderOutput VertexShaderFunction(in VertexShaderInput input) +{ + VertexShaderOutput output; + output.Position = mul(input.Position, uTransformMatrix); + output.Color = input.Color; + output.TextureCoordinates = input.TextureCoordinates; + return output; +} + +float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 +{ + float4 color = input.Color; + float2 coords = input.TextureCoordinates; + + // Fade out at the horizontal and vertical ends of the streak. + float horizonatalDistanceFromCenter = distance(0.5, coords.y); + float opacity = smoothstep(0.5, 0.5 - 0.486, horizonatalDistanceFromCenter); + + // Glow from the center go out. + float glow = pow(0.1 / horizonatalDistanceFromCenter, glowPower); + + float2 distortionCoords = coords + float2(time * -3.12, 0); + distortionCoords *= float2(0.25, 1); + float distortion = tex2D(distortionTexture, distortionCoords).r * 0.43; + + float2 streakCoords = coords + float2(time * -2.34, 0); + streakCoords *= float2(1.25, 1); + float4 streakMapColor = tex2D(baseStreakTexture, streakCoords + distortion); + + float4 returnColor = (streakMapColor * color * glow) * opacity; + returnColor = round(returnColor * 7) / 7; + return returnColor; +} + +technique Technique1 +{ + pass TrailPass + { + VertexShader = compile vs_2_0 VertexShaderFunction(); + PixelShader = compile ps_2_0 PixelShaderFunction(); + } +} \ No newline at end of file diff --git a/Effects/ProvidenceHolyOrbTrailShader.xnb b/Effects/ProvidenceHolyOrbTrailShader.xnb new file mode 100644 index 0000000000000000000000000000000000000000..dda2ab7acc51bea346d761e05c5b53108f9cd75e GIT binary patch literal 2444 zcmb_ePiP}m82@G_DOqtYAq|b?ppiez;X9-MW^M7mY2KQXo$MEDXbmg z&YKTIzvf!)UAx|yH{TR)$97uFh1>!^^JcNz^t!HCZi%kvTFrU0+}&>4_1DGw6=zSh zmX`|odShu@T-p(f3yX^{5tBB`5dD1i{?U_Cjb7TBaD1di@)H;NA zWS<<9>91&zZ!R}3nbMFwd!NghU@xl47^hUO_noG5P<9T4o4{8T-~^s?YTJjRX>lLc ztvWgalZ?&Z;AGw0o9w^XIW9`Gn`Nuhfqa&AQQvLZ?{>u{x-bKsQ{Y;-UiNzdtf&Ct zno=fRWi4B`3f+L z&VJi&Lb#mEznr_gn9t>x3I!U6bt-RO-O}{h`Z&Be>C0R2&NhxG`=XJ_Jy`(rcVPPx zn7_H)+x+i)&{~%h~q0#{Ycuz;VczP8x>qdkE924Z-4f~pPAw9XFtAo z5Yx_d!`u7!uvU5i=+o!2JF1 z-x))U;MG;Or(pl-_;{JfzXD!)F!$RPwx=aNSYaE{-BqkvVfzg1FKo;LJEiBM&*$S7 z=uKr~5X(KvWCJB@kWnX&fd)JczyWH7Nrzq?pbpF#kVk%sehk*6o|U?m83ob2T#NZo z`oihKJPqJS`oj5wULBwh_%nPBzS1-bfbo<5XyPyOkC;8qE%H|#Ad%pCB*r>?`?#+l z>rz%Ywlj|N(&)ULGpHKtjIH`eA}}$pQ%34oE9cQK(n3K@gzEAnm7w}FA$BA-!g zjx*J(G7js?2hT_KMn2Qv150_g1_|eYKDA`-MJ7dm6pM wcgptgj}m&W4SBDCgGkq TrailNoiseTexture { get; private set; } + public static Asset TrailDistortionTexture { get; private set; } + bool started = false; + public new string LocalizationCategory => "Projectiles.Boss"; public override string Texture => "CalamityMod/Projectiles/StarProj"; + public override void Load() + { + if (!Main.dedServ) + { + TrailNoiseTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise"); + TrailDistortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2"); + } + } + public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Type] = 32; - ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 12; + ProjectileID.Sets.TrailingMode[Type] = 0; } public override void SetDefaults() { @@ -87,59 +100,6 @@ namespace CalamityMod.Projectiles.Boss Projectile.position -= (Projectile.velocity / Projectile.MaxUpdates) * (Projectile.MaxUpdates - 1); } - public override bool PreDraw(ref Color lightColor) - { - //drawn by the HolyBurnOrbDrawer system - return false; - } - public float FireWidthFunction(float completion, Vector2 pos) - { - float width; - float maxBodyWidth = 32f * Projectile.scale; - float curveRatio = 0.2f; - var positions = Projectile.oldPos.ToList(); - positions.RemoveAll(x => x == Vector2.Zero); - // Crop the tip of the trail into a conic shape. - if (completion < curveRatio) - width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; - else - width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); - - // Pulse inwards and outwards over time. - float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; - float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); - return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; - } - - public Color FireColorFunction(float completion, Vector2 pos) - { - Color mainColor = ProvUtils.GetProjectileColor(255) * 1.3f; - Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); - return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; - } - - public float FireCoreWidthFunction(float completion, Vector2 pos) - { - float width; - float maxBodyWidth = Projectile.scale * 24; - float curveRatio = 0.25f; - var positions = Projectile.oldPos.ToList(); - positions.RemoveAll(x => x == Vector2.Zero); - - if (completion < curveRatio) - width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; - else - width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); - return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; - } - - public Color FireCoreColorFunction(float completion, Vector2 pos) - { - Color mainColor = ProvUtils.GetProjectileColor(255); - Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); - Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); - return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity; - } public override void OnKill(int timeLeft) { @@ -173,191 +133,206 @@ namespace CalamityMod.Projectiles.Boss ProvUtils.ApplyDebuffs(target, 120); } - } - - public class HolyBurnOrbDrawer : ModSystem - { - public override void Load() + public float FireWidthFunction(float completion) { - On_Main.DrawProjectiles += DrawAll; + float width; + float maxBodyWidth = 36f * Projectile.scale; + float curveRatio = 0.2f; + + // Crop the tip of the trail into a conic shape. + if (completion < curveRatio) + width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + // Pulse inwards and outwards over time. + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 12f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 6f, pulseInterpolant); + return (width + additionalPulseWidth); } - private void DrawAll(On_Main.orig_DrawProjectiles orig, Main self) + public Color FireColorFunction(float completion) { - orig(self); - - var device = Main.instance.GraphicsDevice; - - List burnToDraw = []; - List healToDraw = []; - - - foreach (var item in Main.ActiveProjectiles) - { - if (item.type == ModContent.ProjectileType()) - burnToDraw.Add(item); - - if (item.type == ModContent.ProjectileType()) - healToDraw.Add(item); - } - - if ((healToDraw.Count() + burnToDraw.Count()) < 1) - return; - - using (Main.spriteBatch.Scope()) - { - - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - - //Burn trails - using (ProvUtils.PrimaryLease.Scope(clearColor: Color.Transparent)) - { - foreach (var item in burnToDraw) - DrawBurnOrbTrail(item); - - } - Main.spriteBatch.Draw(ProvUtils.PrimaryLease.Target, Vector2.Zero, null, Color.White * 0.75f, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); - - //Heal trail - using (ProvUtils.SecondaryLease.Scope(clearColor: Color.Transparent)) - { - foreach (var item in healToDraw) - DrawHealOrbTrail(item); - - } - Main.spriteBatch.Draw(ProvUtils.SecondaryLease.Target, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0f); - - //Main orb - foreach (var item in burnToDraw) - DrawBurnOrb(item); - foreach (var item in healToDraw) - DrawHealOrb(item); - - //Additive orb - Main.spriteBatch.End(); - Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); - foreach (var item in burnToDraw) - DrawBurnOrbAdditive(item); - foreach (var item in healToDraw) - DrawHealOrbAdditive(item); - Main.spriteBatch.End(); - } + Color mainColor = Color.Lerp(ProvUtils.GetProjectileColor(255, true) * 2f, ProvUtils.GetProjectileColor(255), 0.75f); + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; } - void DrawBurnOrbTrail(Projectile Projectile) + public override bool PreDraw(ref Color lightColor) { - if (Projectile.ModProjectile is HolyBurnOrb M) - { - var tex = GeneralParticleHandler.GetTexture(GeneralParticleHandler.particleIDsByTypes[typeof(BloomParticle)]); - var len = Math.Min(Projectile.oldPos.Length, 32); - for (var i = 0; i < len; i++) - { - Vector2 drawPos = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color color = M.FireColorFunction(i / (float)len, Projectile.oldPos[i]); - var color2 = ProvUtils.GetProjectileColor(255, true); - float width = M.FireWidthFunction(i / (float)len, Projectile.oldPos[i]); - Main.spriteBatch.Draw(tex, drawPos, null, (color2 with { A = 0 }) * (1 - i / (float)len), 0f, tex.Size() * 0.5f, new Vector2(width) / tex.Width, SpriteEffects.None, 0f); - Main.spriteBatch.Draw(tex, drawPos, null, (color with { A = 0 }) * (1 - i / (float)len), 0f, tex.Size() * 0.5f, new Vector2(width) / tex.Width * 0.25f, SpriteEffects.None, 0f); - } - } - } - void DrawBurnOrb(Projectile Projectile) - { - float lerpMult = MathHelper.Lerp(0.5f, 1.5f, Math.Abs(MathF.Sin(Projectile.localAI[1] / 10f))); - - Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color baseColor = ProvUtils.GetProjectileColor(255, true) * 4; - Color baseColor2 = ProvUtils.GetProjectileColor(255); - baseColor.A = 0; - baseColor *= lerpMult; - baseColor2 *= lerpMult; - Vector2 origin = texture.Size() / 2f; - Vector2 scale = new Vector2(0.5f, 1f) * ((lerpMult - 1) * 0.5f + 1f); - - SpriteEffects spriteEffects = SpriteEffects.None; - if (Projectile.spriteDirection == -1) - spriteEffects = SpriteEffects.FlipHorizontally; - - Projectile.rotation += MathHelper.ToRadians(lerpMult * 2f); - - float upRight = MathHelper.PiOver4; - float up = MathHelper.PiOver2; - float upLeft = 3f * MathHelper.PiOver4; - float left = MathHelper.Pi; - Main.EntitySpriteDraw(texture, drawPos, null, baseColor, upLeft + Projectile.rotation, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, baseColor, upRight - Projectile.rotation, origin, scale, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, upLeft + Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, upRight - Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, baseColor, up + Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, baseColor, left - Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, up + Projectile.rotation, origin, scale * 0.36f, spriteEffects, 0); - Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, left - Projectile.rotation, origin, scale * 0.36f, spriteEffects, 0); + // Trail drawn by the HolyBurnOrbDrawer system. + DrawBurnOrb(); + DrawBurnOrbAdditive(); + return false; } - void DrawBurnOrbAdditive(Projectile Projectile) + private void DrawBurnOrb() { - var texture = ModContent.Request("CalamityMod/Particles/GlowOrbParticle").Value; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, ProvUtils.GetProjectileColor(255), 0, texture.Size() * 0.5f, 1f, 0, 0f); - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Color.White, 0, texture.Size() * 0.5f, 0.5f, 0, 0f); - } - void DrawHealOrbTrail(Projectile Projectile) - { - if (Projectile.ModProjectile is HolyLight M) - { - var tex = GeneralParticleHandler.GetTexture(GeneralParticleHandler.particleIDsByTypes[typeof(BloomParticle)]); - var len = Math.Min(Projectile.oldPos.Length, 32); - for (var i = 0; i < len; i++) - { - Vector2 drawPos = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Color color = M.FireCoreColorFunction(i / (float)len, Projectile.oldPos[i]); - var color2 = new Color(0, 25, 0); - float width = M.FireWidthFunction(i / (float)len, Projectile.oldPos[i]); - Main.spriteBatch.Draw(tex, drawPos, null, (color2 with { A = 0 }) * (1 - i / (float)len), 0f, tex.Size() * 0.5f, new Vector2(width) / tex.Width, SpriteEffects.None, 0f); - Main.spriteBatch.Draw(tex, drawPos, null, (color with { A = 0 }) * (1 - i / (float)len), 0f, tex.Size() * 0.5f, new Vector2(width) / tex.Width * 0.25f, SpriteEffects.None, 0f); - } - } - } - void DrawHealOrb(Projectile Projectile) - { - float vel = Projectile.velocity.Length() / 8; - Projectile.localAI[1] += vel; + float lerpMult = MathHelper.Lerp(0.5f, 1.5f, Math.Abs(MathF.Sin(Projectile.localAI[1] / 10f))); - Texture2D drawTexture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; - Color brightGreen = new Color(54, 209, 54, 0); - Vector2 projDirection = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); - Vector2 halfTextureSize = drawTexture.Size() / 2f; - Color halfBrightGreen = brightGreen * 0.5f; - float timeLeftColorScale = MathHelper.Lerp(0.5f, 1.5f, Math.Abs(MathF.Sin(Projectile.localAI[1] / 10f))); - Projectile.rotation += MathHelper.ToRadians(timeLeftColorScale * 2f); - Vector2 timeLeftDrawEffect = new Vector2(0.5f, 1f) * timeLeftColorScale; - Vector2 timeLeftDrawEffect2 = new Vector2(0.5f, 1f) * timeLeftColorScale; - brightGreen *= timeLeftColorScale; - halfBrightGreen *= timeLeftColorScale; - - Vector2 position3 = projDirection + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * 0; + Texture2D texture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Vector2 drawPos = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + Color baseColor = ProvUtils.GetProjectileColor(255, true) * 4; + Color baseColor2 = ProvUtils.GetProjectileColor(255); + baseColor.A = 0; + baseColor *= lerpMult; + baseColor2 *= lerpMult; + Vector2 origin = texture.Size() * 0.5f; + Vector2 scale = new Vector2(0.5f, 1f) * ((lerpMult - 1) * 0.5f + 1f); SpriteEffects spriteEffects = SpriteEffects.None; if (Projectile.spriteDirection == -1) spriteEffects = SpriteEffects.FlipHorizontally; - Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); + Projectile.rotation += MathHelper.ToRadians(lerpMult * 2f); - Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.36f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.36f, spriteEffects, 0); + float upRight = MathHelper.PiOver4; + float up = MathHelper.PiOver2; + float upLeft = 3f * MathHelper.PiOver4; + float left = MathHelper.Pi; + Main.EntitySpriteDraw(texture, drawPos, null, baseColor, upLeft + Projectile.rotation, origin, scale, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, baseColor, upRight - Projectile.rotation, origin, scale, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, upLeft + Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, upRight - Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, baseColor, up + Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, baseColor, left - Projectile.rotation, origin, scale * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, up + Projectile.rotation, origin, scale * 0.36f, spriteEffects, 0); + Main.EntitySpriteDraw(texture, drawPos, null, baseColor2, left - Projectile.rotation, origin, scale * 0.36f, spriteEffects, 0); } - void DrawHealOrbAdditive(Projectile Projectile) + private void DrawBurnOrbAdditive() { var texture = ModContent.Request("CalamityMod/Particles/GlowOrbParticle").Value; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, new Color(54, 209, 54), 0, texture.Size() * 0.5f, 1f, 0, 0f); - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Color.White, 0, texture.Size() * 0.5f, 0.5f, 0, 0f); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, ProvUtils.GetProjectileColor(255) with { A = 0 }, 0, texture.Size() * 0.5f, 1f, 0, 0f); + Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, texture.Size() * 0.5f, 0.5f, 0, 0f); + } + } + + public class HolyBurnOrbDrawer : ModSystem + { + public static RenderTargetLease TrailPixelationLease { get; private set; } + + private List HolyBurnOrbs = []; + private List HolyLights = []; + + public override void Load() + { + GeneralDrawLayerSystem.OnBeforeProjectiles += DrawOrbTrails; + Main.QueueMainThreadAction(() => TrailPixelationLease = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ( w / 2, h / 2))); + } + + public override void PostUpdateProjectiles() + { + foreach (var item in Main.ActiveProjectiles) + { + if (item.type == ModContent.ProjectileType() && !HolyBurnOrbs.Contains(item)) + HolyBurnOrbs.Add(item); + if (item.type == ModContent.ProjectileType() && !HolyLights.Contains(item)) + HolyLights.Add(item); + } + + HolyBurnOrbs.RemoveAll(p => !p.active || p.timeLeft <= 1); + HolyLights.RemoveAll(p => !p.active || p.timeLeft <= 1); + } + + private void DrawOrbTrails() + { + if ((HolyBurnOrbs.Count + HolyLights.Count) > 0) + { + using (Main.spriteBatch.Scope()) + { + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Matrix.Identity); + using (TrailPixelationLease.Scope(clearColor: Color.Transparent)) + { + foreach (var item in HolyBurnOrbs) + DrawBurnOrbTrail(item); + + foreach (var item in HolyLights) + DrawHealOrbTrail(item); + } + + Main.spriteBatch.End(); + Main.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); + + // Redraw at double scale to pixelate the trails. + Main.spriteBatch.Draw(TrailPixelationLease.Target, Vector2.Zero, null, Color.White with { A = 0 }, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0f); + + Main.spriteBatch.End(); + } + } + } + + private static void DrawBurnOrbTrail(Projectile Projectile) + { + if (Projectile.ModProjectile is HolyBurnOrb orb) + { + Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f); + Vector2 basePosition = Projectile.Center - Main.screenPosition; + Rectangle screenBounds = new Rectangle(-40, -40, Main.screenWidth + 40, Main.screenHeight + 40); + if (screenBounds.Contains(basePosition.ToPoint())) + { + List path = []; + for (var i = 0; i < Projectile.oldPos.Length; i++) + { + Vector2 trailDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + path.Add(new Vector3(trailDrawPosition.X, trailDrawPosition.Y, 0f)); + } + + if (path.Count > 2 && Projectile.ai[0] > 6) + { + Effect shader = CalamityShaders.ProvidenceHolyOrbTrailShader.Value; + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["glowPower"].SetValue(1.48f); + shader.Parameters["pixelationFactor"].SetValue(Main.ScreenSize.ToVector2() * 0.25f); + + Main.graphics.GraphicsDevice.Textures[0] = HolyBurnOrb.TrailNoiseTexture.Value; + Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; + Main.graphics.GraphicsDevice.Textures[1] = HolyBurnOrb.TrailDistortionTexture.Value; + Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + using var shaderScope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, Matrix.Identity, projection); + using var trailMesh = TriangleStripBuilder.BuildStripPooled(path, progress => orb.FireWidthFunction(progress), progress => orb.FireColorFunction(progress), PrimitiveMeshCache.Shared, textured: true); + shaderScope.Draw(trailMesh.View); + } + } + } + } + + private static void DrawHealOrbTrail(Projectile Projectile) + { + if (Projectile.ModProjectile is HolyLight light) + { + Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f); + Vector2 basePosition = Projectile.Center - Main.screenPosition; + Rectangle screenBounds = new Rectangle(-40, -40, Main.screenWidth + 40, Main.screenHeight + 40); + if (screenBounds.Contains(basePosition.ToPoint())) + { + List path = []; + for (var i = 0; i < Projectile.oldPos.Length; i++) + { + Vector2 trailDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + path.Add(new Vector3(trailDrawPosition.X, trailDrawPosition.Y, 0f)); + } + + if (path.Count > 2 && Projectile.ai[0] > 6) + { + Effect shader = CalamityShaders.ProvidenceHolyOrbTrailShader.Value; + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["glowPower"].SetValue(1.22f); + shader.Parameters["pixelationFactor"].SetValue(Main.ScreenSize.ToVector2() * 0.25f); + + Main.graphics.GraphicsDevice.Textures[0] = HolyLight.TrailNoiseTexture.Value; + Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; + Main.graphics.GraphicsDevice.Textures[1] = HolyLight.TrailDistortionTexture.Value; + Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + using var shaderScope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, Matrix.Identity, projection); + using var trailMesh = TriangleStripBuilder.BuildStripPooled(path, progress => light.FireWidthFunction(progress), progress => light.FireColorFunction(progress), PrimitiveMeshCache.Shared, textured: true); + shaderScope.Draw(trailMesh.View); + } + } + } } } } diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 71fcbfaa70..67e02c7cf7 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -1,13 +1,10 @@ using System; -using System.Linq; using CalamityMod.Dusts; using CalamityMod.Enums; -using CalamityMod.NPCs.Providence; using CalamityMod.Particles; -using CalamityMod.Utilities.Daybreak; -using CalamityMod.Utilities.Daybreak.Buffers; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.Audio; using Terraria.DataStructures; @@ -18,13 +15,27 @@ namespace CalamityMod.Projectiles.Boss { public class HolyLight : ModProjectile, ILocalizedModType { + public static Asset TrailNoiseTexture { get; private set; } + public static Asset TrailDistortionTexture { get; private set; } + public new string LocalizationCategory => "Projectiles.Boss"; public override string Texture => "CalamityMod/Projectiles/StarProj"; + + public override void Load() + { + if (!Main.dedServ) + { + TrailNoiseTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak"); + TrailDistortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise"); + } + } + public override void SetStaticDefaults() { - ProjectileID.Sets.TrailCacheLength[Type] = 32; - ProjectileID.Sets.TrailingMode[Type] = 2; + ProjectileID.Sets.TrailCacheLength[Type] = 16; + ProjectileID.Sets.TrailingMode[Type] = 0; } + public override void SetDefaults() { Projectile.localAI[1] = Main.rand.NextFloat(30f); @@ -85,60 +96,6 @@ namespace CalamityMod.Projectiles.Boss } } - public override bool PreDraw(ref Color lightColor) - { - //drawn by the HolyBurnOrbDrawer system - return false; - } - public float FireWidthFunction(float completion, Vector2 pos) - { - float width; - float maxBodyWidth = 32f * Projectile.scale; - float curveRatio = 0.2f; - var positions = Projectile.oldPos.ToList(); - positions.RemoveAll(x => x == Vector2.Zero); - // Crop the tip of the trail into a conic shape. - if (completion < curveRatio) - width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; - else - width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); - - // Pulse inwards and outwards over time. - float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; - float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); - return (width + additionalPulseWidth) * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; - } - - public Color FireColorFunction(float completion, Vector2 pos) - { - Color mainColor = new Color(54, 209, 54) * 1.3f; - Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); - return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; - } - - public float FireCoreWidthFunction(float completion, Vector2 pos) - { - float width; - float maxBodyWidth = Projectile.scale * 24; - float curveRatio = 0.25f; - var positions = Projectile.oldPos.ToList(); - positions.RemoveAll(x => x == Vector2.Zero); - - if (completion < curveRatio) - width = MathF.Sin(completion / curveRatio * MathHelper.PiOver2) * maxBodyWidth + curveRatio; - else - width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); - return width * positions.Count() / (float)ProjectileID.Sets.TrailCacheLength[Type]; - } - - public Color FireCoreColorFunction(float completion, Vector2 pos) - { - Color mainColor = new Color(54, 209, 54); - Color tipColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); - Color fullBodyColor = Color.Lerp(mainColor, tipColor, completion); - return Color.Lerp(fullBodyColor, Color.White, 0.175f) * Projectile.Opacity; - } - public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item14 with { Pitch = -0.3f, Volume = 0.7f }, Projectile.Center); @@ -162,5 +119,79 @@ namespace CalamityMod.Projectiles.Boss dust.noLightEmittence = true; } } + + public float FireWidthFunction(float completion) + { + float width; + float maxBodyWidth = 56f * Projectile.scale; + float curveRatio = 0.2f; + + // Crop the tip of the trail into a conic shape. + if (completion < curveRatio) + width = MathF.Pow(completion / curveRatio, 0.5f) * maxBodyWidth; + else + width = Utils.Remap(completion, curveRatio, 1f, maxBodyWidth, 0f); + + // Pulse inwards and outwards over time. + float pulseInterpolant = MathF.Cos(MathHelper.Pi * completion - Main.GlobalTimeWrappedHourly * 20f) * 0.5f + 0.5f; + float additionalPulseWidth = MathHelper.Lerp(0f, 12f, pulseInterpolant); + return (width + additionalPulseWidth); + } + + public Color FireColorFunction(float completion) + { + Color mainColor = new Color(54, 209, 54) * 1.3f; + Color endColor = Color.Lerp(mainColor, Color.Transparent, Utils.GetLerpValue(0.8f, 1f, completion, true)); + return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; + } + + public override bool PreDraw(ref Color lightColor) + { + // Trail drawn by the HolyBurnOrbDrawer system. + DrawHealOrb(); + DrawHealOrbAdditive(); + return false; + } + + private void DrawHealOrb() + { + float vel = Projectile.velocity.Length() / 8; + Projectile.localAI[1] += vel; + + Texture2D drawTexture = Terraria.GameContent.TextureAssets.Projectile[Projectile.type].Value; + Color brightGreen = new Color(54, 209, 54, 0); + Vector2 projDirection = Projectile.Center - Main.screenPosition + new Vector2(0f, Projectile.gfxOffY); + Vector2 halfTextureSize = drawTexture.Size() / 2f; + Color halfBrightGreen = brightGreen * 0.5f; + float timeLeftColorScale = MathHelper.Lerp(0.5f, 1.5f, Math.Abs(MathF.Sin(Projectile.localAI[1] / 10f))); + Projectile.rotation += MathHelper.ToRadians(timeLeftColorScale * 2f); + Vector2 timeLeftDrawEffect = new Vector2(0.5f, 1f) * timeLeftColorScale; + Vector2 timeLeftDrawEffect2 = new Vector2(0.5f, 1f) * timeLeftColorScale; + brightGreen *= timeLeftColorScale; + halfBrightGreen *= timeLeftColorScale; + + Vector2 position3 = projDirection + Projectile.velocity.SafeNormalize(Vector2.Zero) * Utils.GetLerpValue(0.5f, 1f, Projectile.localAI[0] / 60f, clamped: true) * 0; + + SpriteEffects spriteEffects = SpriteEffects.None; + if (Projectile.spriteDirection == -1) + spriteEffects = SpriteEffects.FlipHorizontally; + + Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); + + Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.36f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.36f, spriteEffects, 0); + } + + private void DrawHealOrbAdditive() + { + var texture = ModContent.Request("CalamityMod/Particles/GlowOrbParticle").Value; + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, new Color(54, 209, 54) with { A = 0 }, 0, texture.Size() * 0.5f, 1f, 0, 0f); + Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, texture.Size() * 0.5f, 0.5f, 0, 0f); + } } } From d3d05082145e14c0a2cb0d404aba226576a6a385 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Mon, 29 Jun 2026 21:44:40 -0400 Subject: [PATCH 3/5] Teleportation Potion Abyss avoidance rewrite * Rewrote the logic for finding a new teleportation spot for the player whenever a Teleportation Potion is drank and finds a location in the Abyss. The old logic simply copy-pasted the Vanilla Teleportation Potion logic and thus still had a chance to send the player to the Abyss. This new logic actively avoids the horizontal slice of the world where the Abyss is located and should nullify any chance of being teleported there naturally. --- ILEditing/MechanicILChanges.cs | 92 ++++++++++++++++++++++++++++++---- 1 file changed, 83 insertions(+), 9 deletions(-) diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index f7466891f6..b01544e1ca 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -30,6 +30,7 @@ using CalamityMod.Tiles; using CalamityMod.Utilities.Daybreak; using CalamityMod.Walls; using CalamityMod.Walls.UnsafeWalls; +using CalamityMod.World; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Mono.Cecil.Cil; @@ -1118,19 +1119,92 @@ namespace CalamityMod.ILEditing { // If an Abyss wall is detected, try to find another teleportation location bool canSpawn = false; - int teleportStartX = 100; + int halfWorldWidth = Main.maxTilesX / 2; + + int teleportStartX = Abyss.AtLeftSideOfWorld ? halfWorldWidth - (halfWorldWidth - 175) + 35 : halfWorldWidth + (halfWorldWidth - 175) - 35; int teleportRangeX = Main.maxTilesX - 200; int teleportStartY = 100; - int underworldLayer = Main.UnderworldLayer; - Vector2 newerPos = self.CheckForGoodTeleportationSpot(ref canSpawn, teleportStartX, teleportRangeX, teleportStartY, underworldLayer, new Player.RandomTeleportationAttemptSettings + int teleportRangeY = Main.UnderworldLayer; + + int attempts = 0; + int maxAttempts = 1000; + int teleportPositionX = 0; + int teleportPositionY = 0; + Vector2 teleportPosition = new Vector2(teleportPositionX, teleportPositionY) * 16f - new Vector2(self.width * 0.5f + 8, self.height); + while (!canSpawn && attempts < maxAttempts) { - avoidLava = true, - avoidHurtTiles = true, - maximumFallDistanceFromOrignalPoint = 100, - attemptsBeforeGivingUp = 1000 - }); + attempts++; + + if (Abyss.AtLeftSideOfWorld) + teleportPositionX = teleportStartX + Main.rand.Next(teleportRangeX); + else + teleportPositionX = teleportStartX - Main.rand.Next(teleportRangeX); + teleportPositionY = teleportStartY + Main.rand.Next(teleportRangeY); + + teleportPositionX = MathHelper.Clamp(teleportPositionX, 5, Main.maxTilesX - 5); + teleportPositionY = MathHelper.Clamp(teleportPositionY, 5, Main.maxTilesY - 5); + teleportPosition = new Vector2(teleportPositionX, teleportPositionY) * 16f - new Vector2(self.width * 0.5f + 8, self.height); + + if (Collision.SolidCollision(teleportPosition, self.width, self.height)) + continue; + + Tile tile = Framing.GetTileSafely(new Point(teleportPositionX, teleportPositionY)); + bool behindTempleWalls = tile.WallType == WallID.LihzahrdBrickUnsafe && teleportPositionY > Main.worldSurface && !NPC.downedPlantBoss; + bool behindDungeonWalls = Main.wallDungeon[tile.WallType] && teleportPositionY > Main.worldSurface && !NPC.downedBoss3; + if (behindTempleWalls || behindDungeonWalls) + continue; + + int distanceToGround = 0; + int maxFallDistance = 100; + while (distanceToGround < maxFallDistance) + { + Tile groundTile = Framing.GetTileSafely(new Point(teleportPositionX, teleportPositionY + distanceToGround)); + teleportPosition = new Vector2(teleportPositionX, teleportPositionY + distanceToGround) * 16f - new Vector2(self.width * 0.5f + 8, self.height); + Collision.SlopeCollision(teleportPosition, self.velocity, self.width, self.height, self.gravDir); + if (!Collision.SolidCollision(teleportPosition, self.width, self.height)) + { + distanceToGround++; + continue; + } + + if (groundTile.HasUnactuatedTile && Main.tileSolid[groundTile.TileType]) + break; + + distanceToGround++; + } + + teleportPosition.Y -= 16f; + bool inLava = Collision.LavaCollision(teleportPosition, self.width, self.height); + bool onHurtingTile = Collision.AnyHurtingTiles(teleportPosition, self.width, self.height); + bool insideBlocks = Collision.SolidCollision(teleportPosition, self.width, self.height); + bool reachedMaxFallDistance = distanceToGround >= maxFallDistance; + if (inLava || onHurtingTile || insideBlocks || reachedMaxFallDistance) + continue; + + Vector2 checkDirection = Vector2.UnitX * 16f; + if (Collision.TileCollision(teleportPosition - checkDirection, checkDirection, self.width, self.height, false, false, (int)self.gravDir) != checkDirection) + continue; + + checkDirection = Vector2.UnitX * -16f; + if (Collision.TileCollision(teleportPosition - checkDirection, checkDirection, self.width, self.height, false, false, (int)self.gravDir) != checkDirection) + continue; + + checkDirection = Vector2.UnitY * 16f; + if (Collision.TileCollision(teleportPosition - checkDirection, checkDirection, self.width, self.height, false, false, (int)self.gravDir) == checkDirection) + { + checkDirection = Vector2.UnitY * -16f; + if (Collision.TileCollision(teleportPosition - checkDirection, checkDirection, self.width, self.height, false, false, (int)self.gravDir) == checkDirection) + { + canSpawn = true; + teleportPositionY += distanceToGround; + teleportPosition = new Vector2(teleportPositionX, teleportPositionY) * 16f - new Vector2(self.width * 0.5f + 8, self.height); + break; + } + } + } + // Attempt teleporting again with the new location - orig(self, newerPos, Style, extraInfo); + orig(self, teleportPosition, Style, extraInfo); } else { From 2050728628ec95c5aba41d713cbd67cb24a3c333 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Mon, 29 Jun 2026 22:06:52 -0400 Subject: [PATCH 4/5] Cleanup * Removed PrimaryLease and SecondaryLease from ProvUtils as they no longer do anything * Made HolyBurnOrb load a glow texture it uses for drawing on load instead of requesting it every frame --- NPCs/Providence/Providence.cs | 8 -------- Projectiles/Boss/HolyBurnOrb.cs | 7 ++++--- Projectiles/Boss/HolyLight.cs | 2 +- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 7bbc1a0e1c..eafcbd03ef 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -2873,14 +2873,6 @@ namespace CalamityMod.NPCs.Providence // These will be used for almost every single one of her projectiles, so it's useful to have. public static class ProvUtils { - /// - /// This lease should be used to draw all of a projectile's effects onto directly, then be drawn onto the screen as one. This is for opacity reasons - /// - public static RenderTargetLease PrimaryLease { get => field ??= ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); set; } - /// - /// This should be used for secondary effects like trails, then drawn to PrimaryLease. This is for opacity reasons. - /// - public static RenderTargetLease SecondaryLease { get => field ??= ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice); set; } public static bool StandardAI() => (CalamityGlobalNPC.holyBoss == -1 || !Main.npc[CalamityGlobalNPC.holyBoss].Calamity().CurrentlyEnraged) && !Main.zenithWorld; public static int CalculateProvidenceDamage(this int damage) diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index 5e6bf93e07..23e4f306fa 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -22,6 +22,7 @@ namespace CalamityMod.Projectiles.Boss { public static Asset TrailNoiseTexture { get; private set; } public static Asset TrailDistortionTexture { get; private set; } + public static Asset GlowOrbTexture { get; private set; } bool started = false; @@ -34,6 +35,7 @@ namespace CalamityMod.Projectiles.Boss { TrailNoiseTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise"); TrailDistortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/Neurons2"); + GlowOrbTexture = ModContent.Request("CalamityMod/Particles/GlowOrbParticle"); } } @@ -203,9 +205,8 @@ namespace CalamityMod.Projectiles.Boss private void DrawBurnOrbAdditive() { - var texture = ModContent.Request("CalamityMod/Particles/GlowOrbParticle").Value; - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, ProvUtils.GetProjectileColor(255) with { A = 0 }, 0, texture.Size() * 0.5f, 1f, 0, 0f); - Main.EntitySpriteDraw(texture, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, texture.Size() * 0.5f, 0.5f, 0, 0f); + Main.EntitySpriteDraw(GlowOrbTexture.Value, Projectile.Center - Main.screenPosition, null, ProvUtils.GetProjectileColor(255) with { A = 0 }, 0, GlowOrbTexture.Size() * 0.5f, 1f, 0, 0f); + Main.EntitySpriteDraw(GlowOrbTexture.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, GlowOrbTexture.Size() * 0.5f, 0.5f, 0, 0f); } } diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 67e02c7cf7..67efa567fa 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -189,7 +189,7 @@ namespace CalamityMod.Projectiles.Boss private void DrawHealOrbAdditive() { - var texture = ModContent.Request("CalamityMod/Particles/GlowOrbParticle").Value; + Texture2D texture = HolyBurnOrb.GlowOrbTexture.Value; Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, new Color(54, 209, 54) with { A = 0 }, 0, texture.Size() * 0.5f, 1f, 0, 0f); Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, texture.Size() * 0.5f, 0.5f, 0, 0f); } From 7665f82597c7899829df77fb178730a286305678 Mon Sep 17 00:00:00 2001 From: fryzahh Date: Tue, 30 Jun 2026 17:42:01 -0400 Subject: [PATCH 5/5] More cleanup + small trail change * Moved the trail drawing functions to their respective ModProjectile classes. HolyBurnOrbDrawer is still contained within the HolyBurnOrb file * Switched to Hermite interpolation and reduced the amount of smoothing segments for the trail drawing to help boost performance more --- Projectiles/Boss/HolyBurnOrb.cs | 119 +++++++++++--------------------- Projectiles/Boss/HolyLight.cs | 58 +++++++++++++--- 2 files changed, 88 insertions(+), 89 deletions(-) diff --git a/Projectiles/Boss/HolyBurnOrb.cs b/Projectiles/Boss/HolyBurnOrb.cs index 23e4f306fa..6978d4aa5d 100644 --- a/Projectiles/Boss/HolyBurnOrb.cs +++ b/Projectiles/Boss/HolyBurnOrb.cs @@ -20,9 +20,9 @@ namespace CalamityMod.Projectiles.Boss { public class HolyBurnOrb : ModProjectile, ILocalizedModType { - public static Asset TrailNoiseTexture { get; private set; } - public static Asset TrailDistortionTexture { get; private set; } - public static Asset GlowOrbTexture { get; private set; } + private static Asset TrailNoiseTexture; + private static Asset TrailDistortionTexture; + private static Asset GlowOrbTexture; bool started = false; @@ -161,6 +161,38 @@ namespace CalamityMod.Projectiles.Boss return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; } + public void DrawTrail() + { + Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f); + Vector2 basePosition = Projectile.Center - Main.screenPosition; + Rectangle screenBounds = new Rectangle(-40, -40, Main.screenWidth + 40, Main.screenHeight + 40); + if (screenBounds.Contains(basePosition.ToPoint())) + { + List path = []; + for (var i = 0; i < Projectile.oldPos.Length; i++) + { + Vector2 trailDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + path.Add(new Vector3(trailDrawPosition.X, trailDrawPosition.Y, 0f)); + } + + if (path.Count > 2 && Projectile.ai[0] > 6) + { + Effect shader = CalamityShaders.ProvidenceHolyOrbTrailShader.Value; + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["glowPower"].SetValue(1.48f); + + Main.graphics.GraphicsDevice.Textures[0] = TrailNoiseTexture.Value; + Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; + Main.graphics.GraphicsDevice.Textures[1] = TrailDistortionTexture.Value; + Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + using var shaderScope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, Matrix.Identity, projection); + using var trailMesh = TriangleStripBuilder.BuildStripPooled(path, progress => FireWidthFunction(progress), progress => FireColorFunction(progress), PrimitiveMeshCache.Shared, textured: true); + shaderScope.Draw(trailMesh.View); + } + } + } + public override bool PreDraw(ref Color lightColor) { // Trail drawn by the HolyBurnOrbDrawer system. @@ -220,7 +252,10 @@ namespace CalamityMod.Projectiles.Boss public override void Load() { GeneralDrawLayerSystem.OnBeforeProjectiles += DrawOrbTrails; - Main.QueueMainThreadAction(() => TrailPixelationLease = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => ( w / 2, h / 2))); + if (!Main.dedServ) + { + Main.QueueMainThreadAction(() => TrailPixelationLease = ScreenspaceTargetPool.Shared.Rent(Main.instance.GraphicsDevice, (w, h) => (w / 2, h / 2))); + } } public override void PostUpdateProjectiles() @@ -247,10 +282,10 @@ namespace CalamityMod.Projectiles.Boss using (TrailPixelationLease.Scope(clearColor: Color.Transparent)) { foreach (var item in HolyBurnOrbs) - DrawBurnOrbTrail(item); + item.ModProjectile().DrawTrail(); foreach (var item in HolyLights) - DrawHealOrbTrail(item); + item.ModProjectile().DrawTrail(); } Main.spriteBatch.End(); @@ -263,77 +298,5 @@ namespace CalamityMod.Projectiles.Boss } } } - - private static void DrawBurnOrbTrail(Projectile Projectile) - { - if (Projectile.ModProjectile is HolyBurnOrb orb) - { - Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f); - Vector2 basePosition = Projectile.Center - Main.screenPosition; - Rectangle screenBounds = new Rectangle(-40, -40, Main.screenWidth + 40, Main.screenHeight + 40); - if (screenBounds.Contains(basePosition.ToPoint())) - { - List path = []; - for (var i = 0; i < Projectile.oldPos.Length; i++) - { - Vector2 trailDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; - path.Add(new Vector3(trailDrawPosition.X, trailDrawPosition.Y, 0f)); - } - - if (path.Count > 2 && Projectile.ai[0] > 6) - { - Effect shader = CalamityShaders.ProvidenceHolyOrbTrailShader.Value; - shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); - shader.Parameters["glowPower"].SetValue(1.48f); - shader.Parameters["pixelationFactor"].SetValue(Main.ScreenSize.ToVector2() * 0.25f); - - Main.graphics.GraphicsDevice.Textures[0] = HolyBurnOrb.TrailNoiseTexture.Value; - Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; - Main.graphics.GraphicsDevice.Textures[1] = HolyBurnOrb.TrailDistortionTexture.Value; - Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; - - using var shaderScope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, Matrix.Identity, projection); - using var trailMesh = TriangleStripBuilder.BuildStripPooled(path, progress => orb.FireWidthFunction(progress), progress => orb.FireColorFunction(progress), PrimitiveMeshCache.Shared, textured: true); - shaderScope.Draw(trailMesh.View); - } - } - } - } - - private static void DrawHealOrbTrail(Projectile Projectile) - { - if (Projectile.ModProjectile is HolyLight light) - { - Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f); - Vector2 basePosition = Projectile.Center - Main.screenPosition; - Rectangle screenBounds = new Rectangle(-40, -40, Main.screenWidth + 40, Main.screenHeight + 40); - if (screenBounds.Contains(basePosition.ToPoint())) - { - List path = []; - for (var i = 0; i < Projectile.oldPos.Length; i++) - { - Vector2 trailDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; - path.Add(new Vector3(trailDrawPosition.X, trailDrawPosition.Y, 0f)); - } - - if (path.Count > 2 && Projectile.ai[0] > 6) - { - Effect shader = CalamityShaders.ProvidenceHolyOrbTrailShader.Value; - shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); - shader.Parameters["glowPower"].SetValue(1.22f); - shader.Parameters["pixelationFactor"].SetValue(Main.ScreenSize.ToVector2() * 0.25f); - - Main.graphics.GraphicsDevice.Textures[0] = HolyLight.TrailNoiseTexture.Value; - Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; - Main.graphics.GraphicsDevice.Textures[1] = HolyLight.TrailDistortionTexture.Value; - Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; - - using var shaderScope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, Matrix.Identity, projection); - using var trailMesh = TriangleStripBuilder.BuildStripPooled(path, progress => light.FireWidthFunction(progress), progress => light.FireColorFunction(progress), PrimitiveMeshCache.Shared, textured: true); - shaderScope.Draw(trailMesh.View); - } - } - } - } } } diff --git a/Projectiles/Boss/HolyLight.cs b/Projectiles/Boss/HolyLight.cs index 67efa567fa..54fc96cc2d 100644 --- a/Projectiles/Boss/HolyLight.cs +++ b/Projectiles/Boss/HolyLight.cs @@ -1,6 +1,9 @@ using System; +using System.Collections.Generic; using CalamityMod.Dusts; +using CalamityMod.Effects; using CalamityMod.Enums; +using CalamityMod.Graphics.Primitives; using CalamityMod.Particles; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -15,8 +18,9 @@ namespace CalamityMod.Projectiles.Boss { public class HolyLight : ModProjectile, ILocalizedModType { - public static Asset TrailNoiseTexture { get; private set; } - public static Asset TrailDistortionTexture { get; private set; } + private static Asset TrailNoiseTexture; + private static Asset TrailDistortionTexture; + private static Asset GlowOrbTexture; public new string LocalizationCategory => "Projectiles.Boss"; public override string Texture => "CalamityMod/Projectiles/StarProj"; @@ -27,6 +31,7 @@ namespace CalamityMod.Projectiles.Boss { TrailNoiseTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/EternityStreak"); TrailDistortionTexture = ModContent.Request("CalamityMod/ExtraTextures/GreyscaleGradients/HarshNoise"); + GlowOrbTexture = ModContent.Request("CalamityMod/Particles/GlowOrbParticle"); } } @@ -145,6 +150,38 @@ namespace CalamityMod.Projectiles.Boss return Color.Lerp(mainColor, endColor, completion) * Projectile.Opacity; } + public void DrawTrail() + { + Matrix projection = Matrix.CreateOrthographicOffCenter(0, Main.screenWidth, Main.screenHeight, 0, -200f, 200f); + Vector2 basePosition = Projectile.Center - Main.screenPosition; + Rectangle screenBounds = new Rectangle(-40, -40, Main.screenWidth + 40, Main.screenHeight + 40); + if (screenBounds.Contains(basePosition.ToPoint())) + { + List path = []; + for (var i = 0; i < Projectile.oldPos.Length; i++) + { + Vector2 trailDrawPosition = Projectile.oldPos[i] + Projectile.Size * 0.5f - Main.screenPosition; + path.Add(new Vector3(trailDrawPosition.X, trailDrawPosition.Y, 0f)); + } + + if (path.Count > 2 && Projectile.ai[0] > 6) + { + Effect shader = CalamityShaders.ProvidenceHolyOrbTrailShader.Value; + shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); + shader.Parameters["glowPower"].SetValue(1.48f); + + Main.graphics.GraphicsDevice.Textures[0] = TrailNoiseTexture.Value; + Main.graphics.GraphicsDevice.SamplerStates[0] = SamplerState.PointWrap; + Main.graphics.GraphicsDevice.Textures[1] = TrailDistortionTexture.Value; + Main.graphics.GraphicsDevice.SamplerStates[1] = SamplerState.LinearWrap; + + using var shaderScope = SanePrimitiveRenderer.BeginShaderScope(shader, Matrix.Identity, Matrix.Identity, projection); + using var trailMesh = TriangleStripBuilder.BuildStripPooled(path, progress => FireWidthFunction(progress), progress => FireColorFunction(progress), PrimitiveMeshCache.Shared, textured: true); + shaderScope.Draw(trailMesh.View); + } + } + } + public override bool PreDraw(ref Color lightColor) { // Trail drawn by the HolyBurnOrbDrawer system. @@ -178,20 +215,19 @@ namespace CalamityMod.Projectiles.Boss Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect, spriteEffects, 0); Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3 + Vector2.UnitX * 60f, null, halfBrightGreen, MathHelper.PiOver2 - Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3 + Vector2.UnitX * 60f, null, halfBrightGreen, 0f - Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, brightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.36f, spriteEffects, 0); - Main.EntitySpriteDraw(drawTexture, position3, null, halfBrightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.36f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3 - Vector2.UnitX * 60f, null, brightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3 - Vector2.UnitX * 60f, null, brightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.6f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3 - Vector2.UnitY * 60f, null, halfBrightGreen, MathHelper.PiOver4 + Projectile.rotation, halfTextureSize, timeLeftDrawEffect * 0.36f, spriteEffects, 0); + Main.EntitySpriteDraw(drawTexture, position3 - Vector2.UnitY * 60f, null, halfBrightGreen, MathHelper.PiOver4 * 3f + Projectile.rotation, halfTextureSize, timeLeftDrawEffect2 * 0.36f, spriteEffects, 0); } private void DrawHealOrbAdditive() { - Texture2D texture = HolyBurnOrb.GlowOrbTexture.Value; - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, new Color(54, 209, 54) with { A = 0 }, 0, texture.Size() * 0.5f, 1f, 0, 0f); - Main.spriteBatch.Draw(texture, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, texture.Size() * 0.5f, 0.5f, 0, 0f); + Main.spriteBatch.Draw(GlowOrbTexture.Value, Projectile.Center - Main.screenPosition, null, new Color(54, 209, 54) with { A = 0 }, 0, GlowOrbTexture.Size() * 0.5f, 1f, 0, 0f); + Main.spriteBatch.Draw(GlowOrbTexture.Value, Projectile.Center - Main.screenPosition, null, Color.White with { A = 0 }, 0, GlowOrbTexture.Size() * 0.5f, 0.5f, 0, 0f); } } }