From 88b50143fc4c8c6b37f9f0e445ad1b5904f7ea19 Mon Sep 17 00:00:00 2001 From: Mishiro Usui Date: Fri, 1 Sep 2023 01:50:52 +0100 Subject: [PATCH] Few files I forgor about --- Cooldowns/ProfanedSoulShield.cs | 127 +++++++++++++++++++++++ Cooldowns/ProfanedSoulShieldActive.png | Bin 0 -> 356 bytes Cooldowns/ProfanedSoulShieldOutline.png | Bin 0 -> 184 bytes Cooldowns/ProfanedSoulShieldOverlay.png | Bin 0 -> 159 bytes Cooldowns/ProfanedSoulShieldRecharge.png | Bin 0 -> 248 bytes 5 files changed, 127 insertions(+) create mode 100644 Cooldowns/ProfanedSoulShield.cs create mode 100644 Cooldowns/ProfanedSoulShieldActive.png create mode 100644 Cooldowns/ProfanedSoulShieldOutline.png create mode 100644 Cooldowns/ProfanedSoulShieldOverlay.png create mode 100644 Cooldowns/ProfanedSoulShieldRecharge.png diff --git a/Cooldowns/ProfanedSoulShield.cs b/Cooldowns/ProfanedSoulShield.cs new file mode 100644 index 0000000000..9035f0b067 --- /dev/null +++ b/Cooldowns/ProfanedSoulShield.cs @@ -0,0 +1,127 @@ +using System; +using CalamityMod.CalPlayer; +using CalamityMod.Items.Accessories; +using CalamityMod.NPCs.Providence; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using Terraria; +using Terraria.Audio; +using Terraria.GameContent; +using Terraria.Graphics.Shaders; +using Terraria.Localization; +using static CalamityMod.CalamityUtils; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Cooldowns +{ + public class ProfanedSoulShield : CooldownHandler + { + + private CalamityPlayer CalPlayer => instance.player.Calamity(); + private int CorrectMaxDurability => CalPlayer.profanedCrystalBuffs + ? ProfanedSoulCrystal.ShieldDurabilityMax + : ProfanedSoulArtifact.ShieldDurabilityMax; + + //Slightly more readable and actually works which is nice + private Color GetColor(bool start) + { + Color result; + if (start) + { + result = CalPlayer.profanedCrystalBuffs ? new Color(247, 172, 131) : new Color(235, 178, 96); + } + else + { + result = CalPlayer.profanedCrystalBuffs ? new Color(255, 194, 161) : new Color(219, 179, 121); + } + return result; + } + + private float AdjustedCompletion => instance.timeLeft / (float)CorrectMaxDurability; + + public static new string ID => "ProfanedSoulShieldDurability"; + public override bool CanTickDown => !CalPlayer.pSoulArtifact || instance.timeLeft <= 0; + public override bool ShouldDisplay => (CalPlayer.pSoulArtifact && !CalPlayer.profanedCrystal) || CalPlayer.profanedCrystalBuffs; + public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/ProfanedSoulShieldActive"; + public override string OutlineTexture => "CalamityMod/Cooldowns/ProfanedSoulShieldOutline"; + public override string OverlayTexture => "CalamityMod/Cooldowns/ProfanedSoulShieldOverlay"; + public override Color OutlineColor => new Color(255, 191, 73); + public override Color CooldownStartColor => Color.Lerp(GetColor(true), GetColor(false), instance.Completion); + public override Color CooldownEndColor => Color.Lerp(GetColor(true), GetColor(false), instance.Completion); + public override bool SavedWithPlayer => false; + public override bool PersistsThroughDeath => false; + + public override void ApplyBarShaders(float opacity) + { + // Use the adjusted completion + GameShaders.Misc["CalamityMod:CircularBarShader"].UseOpacity(opacity); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSaturation(AdjustedCompletion); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseColor(CooldownStartColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].UseSecondaryColor(CooldownEndColor); + GameShaders.Misc["CalamityMod:CircularBarShader"].Apply(); + } + + public override void DrawExpanded(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + base.DrawExpanded(spriteBatch, position, opacity, scale); + + float Xoffset = instance.timeLeft > 9 ? -10f : -5; + DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + new Vector2(Xoffset, 4) * scale, Color.Lerp(GetColor(true), Color.OrangeRed, 1 - instance.Completion), Color.Black, scale); + } + + public override void DrawCompact(SpriteBatch spriteBatch, Vector2 position, float opacity, float scale) + { + Texture2D sprite = Request(Texture).Value; + Texture2D outline = Request(OutlineTexture).Value; + Texture2D overlay = Request(OverlayTexture).Value; + + // Draw the outline + spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + // Draw the icon + spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + // Draw the small overlay + int lostHeight = (int)Math.Ceiling(overlay.Height * AdjustedCompletion); + Rectangle crop = new Rectangle(0, lostHeight, overlay.Width, overlay.Height - lostHeight); + spriteBatch.Draw(overlay, position + Vector2.UnitY * lostHeight * scale, crop, OutlineColor * opacity * 0.9f, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f); + + float Xoffset = instance.timeLeft > 9 ? -10f : -5; + DrawBorderStringEightWay(spriteBatch, FontAssets.MouseText.Value, instance.timeLeft.ToString(), position + new Vector2(Xoffset, 4) * scale, Color.Lerp(GetColor(true), Color.OrangeRed, 1 - instance.Completion), Color.Black, scale); + } + } + + public class ProfanedSoulShieldRecharge : CooldownHandler + { + private static Color ringColorLerpStart = new Color(217, 159, 78); + private static Color ringColorLerpEnd = new Color(214, 185, 144); + + public static new string ID => "ProfanedSoulShieldRecharge"; + public override bool ShouldDisplay => true; + public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}"); + public override string Texture => "CalamityMod/Cooldowns/ProfanedSoulShieldRecharge"; + public override string OutlineTexture => "CalamityMod/Cooldowns/ProfanedSoulShieldOutline"; + public override string OverlayTexture => "CalamityMod/Cooldowns/ProfanedSoulShieldOverlay"; + public override bool SavedWithPlayer => false; + public override bool PersistsThroughDeath => false; + public override Color OutlineColor => new Color(57, 195, 237); + public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); + public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); + + public override void Tick() => instance.player.Calamity().playedProfanedSoulShieldSound = false; + + // When the recharge period completes, grant 1 point of shielding immediately so the rest my refill normally. + // The shield durability cooldown is added elsewhere, in Misc Effects. + public override void OnCompleted() + { + CalamityPlayer modPlayer = instance.player.Calamity(); + if (modPlayer.pSoulShieldDurability <= 0) + modPlayer.pSoulShieldDurability = 1; + //Cooldown end sound can play even in circumstances where it shouldn't, i.e when a shielding accessory's charge cooldown expires and the acc is no longer equipped + //TODO consider a possible edit to cooldown handler to accommodate conditional end sounds. + if (modPlayer.pSoulArtifact) + SoundEngine.PlaySound(Providence.BurnStartSound); + } + } +} diff --git a/Cooldowns/ProfanedSoulShieldActive.png b/Cooldowns/ProfanedSoulShieldActive.png new file mode 100644 index 0000000000000000000000000000000000000000..2e6ac9ca7875d2bfd010b3572cb6522854cad4ef GIT binary patch literal 356 zcmV-q0h|7bP)Px$9!W$&R5*>zlQBy|Q5c4w6A^`Ulbq5^PBvr^Zb6$Zf#lh@#~-*o&TnZRdi|biQ-H3(xt^dtlKqT5PSZBml+Cn$>U{znj_m zAh(gs)~}ym0F1tW48W3a!)13P%xwa&6XpTvT^=U@_orX8b zOq5HZRafc(08bx*Wq7z<03eFTNjipFXl5>rqqbF-OTpa!C>{eT7#iizMS1LX&j2`S zy#UZZZvxZ&x%i)<60X~>?(bO*7dKe|YP%Hx)+77-)x#q&eNp~rsD);!Tc9CYPU(Gcc~_>eN`gJ8f6@f~!lEZ#VX4 zD_!v1bLXI}XqBw;tMZ1l`L6GD%L};H=r8zi`u_Jf_KWt(a@>rqsQk;)#h` gCUAe@nr>ae5OU4`tDKZ^63})APgg&ebxsLQ0IqdJ+W-In literal 0 HcmV?d00001 diff --git a/Cooldowns/ProfanedSoulShieldOverlay.png b/Cooldowns/ProfanedSoulShieldOverlay.png new file mode 100644 index 0000000000000000000000000000000000000000..14d5d4123fac19830b3d9d6159a615cb64c027c9 GIT binary patch literal 159 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VV{wqX6T`Z5GB1IgNKY5X5R2Zo zQw+Hn6nL10KmLzj7wp(2bd-zl-V&ihfh!KYzQCWBc9`MhzjZ~bm-!f0ah>T&TOwU_ z-C<(h5AO35XK#ur$qv4!pHg#UZt9=jchXj;OlDcWY~xjJm619tcEuZL34^DrpUXO@ GgeCxryf<|{Lo_C? zy{Op7(TQV;!IJ^2xfvq3f;c zSN-~Ue`3P4ne7Gss`|wz^S^YSjCiy~jC)PNS($=Ex*b~trtiFvAY0iUE?{j_{JL*- z;|BQ)tN-QPG(7uh`^?AU_CG%Fjo>c4wfxZ`vleBu3YYq@J5u|VkG}TX`AMdE?Wcb6 w-nivaS6=Uap+E6=#YI1vpzJTrFEbvocQUI+%TD~T4Cs0WPgg&ebxsLQ07AlOIsgCw literal 0 HcmV?d00001