diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index c8fdb7c206..90c64afeaa 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3586,12 +3586,16 @@ namespace CalamityMod.CalPlayer // This number is not an integer, and stores exact per-frame recharge progress. lunicCorpsShieldPartialRechargeProgress += LunicCorpsHelmet.ShieldDurabilityMax / (float)LunicCorpsHelmet.TotalShieldRechargeTime; - // Cast to int to get whole number of shield points recharged this frame. - int pointsActuallyRecharged = (int)lunicCorpsShieldPartialRechargeProgress; + // Floor the value to get whole number of shield points recharged this frame. + int pointsActuallyRecharged = (int)MathF.Floor(lunicCorpsShieldPartialRechargeProgress); - // Give those points to the real shield durability. Then remove them from recharge progress. - LunicCorpsShieldDurability += pointsActuallyRecharged; + // Give those points to the real shield durability, capping the result. Then remove them from recharge progress. + LunicCorpsShieldDurability = Math.Min(LunicCorpsShieldDurability + pointsActuallyRecharged, LunicCorpsHelmet.ShieldDurabilityMax); lunicCorpsShieldPartialRechargeProgress -= pointsActuallyRecharged; + + // Update the cooldown rack's durability indicator. + if (cooldowns.TryGetValue(Cooldowns.LunicCorpsShieldDurability.ID, out var cdDurability)) + cdDurability.timeLeft = LunicCorpsShieldDurability; } // Add light if this shield is currently active diff --git a/Cooldowns/LunicCorpsShieldCooldowns.cs b/Cooldowns/LunicCorpsShieldCooldowns.cs index 59e24731d4..54836f1e66 100644 --- a/Cooldowns/LunicCorpsShieldCooldowns.cs +++ b/Cooldowns/LunicCorpsShieldCooldowns.cs @@ -1,6 +1,5 @@ using System; using CalamityMod.CalPlayer; -using CalamityMod.Items.Accessories; using CalamityMod.Items.Armor.LunicCorps; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -82,13 +81,24 @@ namespace CalamityMod.Cooldowns public static new string ID => "MasterChefShieldRecharge"; public override bool ShouldDisplay => true; public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}"); - public override string Texture => "CalamityMod/Cooldowns/MasterChefShieldDurability"; + public override string Texture => "CalamityMod/Cooldowns/LunicCorpsShieldRecharge"; + public override string OutlineTexture => "CalamityMod/Cooldowns/LunicCorpsShieldOutline"; + public override string OverlayTexture => "CalamityMod/Cooldowns/LunicCorpsShieldOverlay"; public override bool SavedWithPlayer => false; public override bool PersistsThroughDeath => false; public override Color OutlineColor => new Color(133, 204, 237); public override Color CooldownStartColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion); public override SoundStyle? EndSound => LunicCorpsHelmet.ActivationSound; + public override void Tick() => instance.player.Calamity().playedLunicCorpsShieldSound = 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.LunicCorpsShieldDurability <= 0) + modPlayer.LunicCorpsShieldDurability = 1; + } } } diff --git a/Cooldowns/LunicCorpsShield.png b/Cooldowns/LunicCorpsShieldRecharge.png similarity index 100% rename from Cooldowns/LunicCorpsShield.png rename to Cooldowns/LunicCorpsShieldRecharge.png diff --git a/Cooldowns/WulfrumRoverDriveCooldowns.cs b/Cooldowns/WulfrumRoverDriveCooldowns.cs index b554e51148..894e7dd7f9 100644 --- a/Cooldowns/WulfrumRoverDriveCooldowns.cs +++ b/Cooldowns/WulfrumRoverDriveCooldowns.cs @@ -81,8 +81,10 @@ namespace CalamityMod.Cooldowns public static new string ID => "WulfrumRoverDriveRecharge"; public override bool ShouldDisplay => true; - public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}"); + public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}"); public override string Texture => "CalamityMod/Cooldowns/WulfrumRoverDrive"; + public override string OutlineTexture => "CalamityMod/Cooldowns/WulfrumRoverDriveOutline"; + public override string OverlayTexture => "CalamityMod/Cooldowns/WulfrumRoverDriveOverlay"; public override bool SavedWithPlayer => false; public override bool PersistsThroughDeath => false; public override Color OutlineColor => new Color(194, 255, 67);