Finished mechanical work on Lunic Corps armor to match Halo

Needs testing and a few TODOs
This commit is contained in:
Ozzatron committed 2023-08-17 15:24:25 -04:00
1 parent 836be908a1
commit fb1df16d79
8 files changed
+81 -37

No files matched your search

+13 -3
View File
@@ -396,7 +396,11 @@ namespace CalamityMod.CalPlayer
public bool roverDrive = false;
public bool roverDriveShieldVisible = false;
// Lunic Corps shield is controlled by its armor set bool
// Lunic Corps shield comes from an armor set and its visibility is non optional
internal float lunicCorpsShieldPartialRechargeProgress = 0f;
public bool sponge = false;
public bool spongeShieldVisible = false;
#endregion
@@ -5814,20 +5818,26 @@ namespace CalamityMod.CalPlayer
roverDriveDurabilityCD.timeLeft = RoverDriveShieldDurability;
// Update Lunic Corps Armor durability on the cooldown rack.
if (lunicCorpsSet && cooldowns.TryGetValue(MasterChefShieldDurability.ID, out var masterChefDurabilityCD))
if (lunicCorpsSet && cooldowns.TryGetValue(Cooldowns.LunicCorpsShieldDurability.ID, out var masterChefDurabilityCD))
masterChefDurabilityCD.timeLeft = LunicCorpsShieldDurability;
// TODO -- Sponge cooldown...
}
// Regardless of whether shields took damage, stop all shield regen on ANY hit.
// Regardless of whether shields took damage, iterate over all shield regen on ANY hit.
// This applies even if you are hit while shields are fully down, or if you unequip any of the relevant items.
{
// Rover Drive does not recharge while partially full, only when broken.
// If you are hit when recharging, though, that timer gets reset.
if (cooldowns.TryGetValue(WulfrumRoverDriveRecharge.ID, out var roverDriveRechargeCD))
roverDriveRechargeCD.timeLeft = RoverDrive.ShieldRechargeTime;
if (cooldowns.TryGetValue(MasterChefShieldRecharge.ID, out var cd))
// If the Lunic Corps Armor is still recharging, reset its recharge delay to full.
if (cooldowns.TryGetValue(LunicCorpsShieldRecharge.ID, out var cd))
cd.timeLeft = LunicCorpsHelmet.ShieldRechargeDelay;
// If the Lunic Corps Armor is not yet recharging, start its recharge timer.
else
Player.AddCooldown(Cooldowns.LunicCorpsShieldRecharge.ID, LunicCorpsHelmet.ShieldRechargeDelay, true);
// TODO -- Stop Sponge cooldown
}
+27 -5
View File
@@ -3527,26 +3527,47 @@ namespace CalamityMod.CalPlayer
// The recharge cooldown is intentionally left in place to prevent hot swapping to recharge the shield
if (!lunicCorpsSet)
{
if (cooldowns.TryGetValue(MasterChefShieldDurability.ID, out var cdDurability))
if (cooldowns.TryGetValue(Cooldowns.LunicCorpsShieldDurability.ID, out var cdDurability))
cdDurability.timeLeft = 0;
// if (cooldowns.TryGetValue(MasterChefShieldRecharge.ID, out var cdRecharge)) cdRecharge.timeLeft = 0;
// As Lunic Corps shields can be left in partially recharged states, this is for safety.
// If the player does not have the armor equipped for even one frame, discharge all shields.
LunicCorpsShieldDurability = 0;
}
// Stuff to do if the Lunic Corps armor is equipped
else
{
if (LunicCorpsShieldDurability == 0 && !cooldowns.ContainsKey(MasterChefShieldRecharge.ID))
Player.AddCooldown(MasterChefShieldRecharge.ID, LunicCorpsHelmet.ShieldRechargeDelay);
// If the Lunic Corps shield is discharged and hasn't started its recharge delay, start that.
if (LunicCorpsShieldDurability == 0 && !cooldowns.ContainsKey(LunicCorpsShieldRecharge.ID))
Player.AddCooldown(LunicCorpsShieldRecharge.ID, LunicCorpsHelmet.ShieldRechargeDelay);
// If the shield has greater than zero durability but that durability is not on the cooldown rack,
// add it to the cooldown rack and play a sound of the shield turning on.
if (LunicCorpsShieldDurability > 0 && !cooldowns.ContainsKey(MasterChefShieldDurability.ID))
if (LunicCorpsShieldDurability > 0 && !cooldowns.ContainsKey(Cooldowns.LunicCorpsShieldDurability.ID))
{
CooldownInstance durabilityCooldown = Player.AddCooldown(MasterChefShieldDurability.ID, LunicCorpsHelmet.ShieldDurabilityMax);
var durabilityCooldown = Player.AddCooldown(Cooldowns.LunicCorpsShieldDurability.ID, LunicCorpsHelmet.ShieldDurabilityMax);
durabilityCooldown.timeLeft = LunicCorpsShieldDurability;
SoundEngine.PlaySound(LunicCorpsHelmet.ActivationSound, Player.Center);
}
// If the shield has greater than zero durability and isn't in its recharge delay, actively replenish shield points.
if (LunicCorpsShieldDurability > 0 && !cooldowns.ContainsKey(LunicCorpsShieldRecharge.ID))
{
// TODO -- sound should be played when recharging starts. This requires extra state tracking
// 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;
// Give those points to the real shield durability. Then remove them from recharge progress.
LunicCorpsShieldDurability += pointsActuallyRecharged;
lunicCorpsShieldPartialRechargeProgress -= pointsActuallyRecharged;
}
// Add light if this shield is currently active
if (LunicCorpsShieldDurability > 0 && !shieldAddedLight)
{
@@ -3567,6 +3588,7 @@ namespace CalamityMod.CalPlayer
// Stuff to do if the Rover Drive is equipped
else
{
// If the Rover Drive shield is discharged and hasn't started its recharge delay, start that.
if (RoverDriveShieldDurability == 0 && !cooldowns.ContainsKey(WulfrumRoverDriveRecharge.ID))
Player.AddCooldown(WulfrumRoverDriveRecharge.ID, RoverDrive.ShieldRechargeTime);
File renamed without changes.

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 259 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 461 B

After

Width:  |  Height:  |  Size: 461 B

@@ -1,34 +1,34 @@
using Microsoft.Xna.Framework;
using System;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Accessories;
using CalamityMod.Items.Armor.LunicCorps;
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;
using CalamityMod.Items.Accessories;
using Terraria.Audio;
using Terraria.Graphics.Shaders;
using System;
using CalamityMod.Items.Armor.LunicCorps;
using CalamityMod.CalPlayer;
namespace CalamityMod.Cooldowns
{
public class MasterChefShieldDurability : CooldownHandler
public class LunicCorpsShieldDurability : CooldownHandler
{
private static Color ringColorLerpStart = new Color(49, 220, 221);
private static Color ringColorLerpEnd = new Color(99, 226, 142);
private static Color ringColorLerpStart = new Color(82, 203, 222);
private static Color ringColorLerpEnd = new Color(113, 178, 222);
private float AdjustedCompletion => (instance.timeLeft) / (float)LunicCorpsHelmet.ShieldDurabilityMax;
private float AdjustedCompletion => instance.timeLeft / (float)LunicCorpsHelmet.ShieldDurabilityMax;
public static new string ID => "MasterChefShieldDurability";
public override bool CanTickDown => !instance.player.GetModPlayer<CalamityPlayer>().lunicCorpsSet || instance.timeLeft <= 0;
public override bool ShouldDisplay => instance.player.GetModPlayer<CalamityPlayer>().lunicCorpsSet;
public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}");
public override string Texture => "CalamityMod/Cooldowns/MasterChefShieldDurabilityActive";
public override string OutlineTexture => "CalamityMod/Cooldowns/MasterChefShieldDurabilityOutline";
public override string OverlayTexture => "CalamityMod/Cooldowns/MasterChefShieldDurabilityOverlay";
public override Color OutlineColor => new Color(112, 244, 244);
public override bool CanTickDown => !instance.player.Calamity().lunicCorpsSet || instance.timeLeft <= 0;
public override bool ShouldDisplay => instance.player.Calamity().lunicCorpsSet;
public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}");
public override string Texture => "CalamityMod/Cooldowns/LunicCorpsShieldActive";
public override string OutlineTexture => "CalamityMod/Cooldowns/LunicCorpsShieldOutline";
public override string OverlayTexture => "CalamityMod/Cooldowns/LunicCorpsShieldOverlay";
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 bool SavedWithPlayer => false;
@@ -74,22 +74,28 @@ namespace CalamityMod.Cooldowns
}
}
public class MasterChefShieldRecharge : CooldownHandler
public class LunicCorpsShieldRecharge : CooldownHandler
{
private static Color ringColorLerpStart = new Color(194, 255, 57);
private static Color ringColorLerpEnd = new Color(92, 187, 99);
private static Color ringColorLerpStart = new Color(179, 212, 242);
private static Color ringColorLerpEnd = new Color(113, 178, 222);
public static new string ID => "MasterChefShieldRecharge";
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/MasterChefShieldDurability";
public override bool SavedWithPlayer => false;
public override bool PersistsThroughDeath => false;
public override Color OutlineColor => new Color(194, 255, 67);
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 void OnCompleted() => instance.player.GetModPlayer<CalamityPlayer>().LunicCorpsShieldDurability = LunicCorpsHelmet.ShieldDurabilityMax;
// Lunic Corps shields gain their first point of durability when this cooldown completes.
public override void OnCompleted()
{
CalamityPlayer modPlayer = instance.player.Calamity();
if (modPlayer.lunicCorpsSet)
modPlayer.LunicCorpsShieldDurability = 1;
}
public override SoundStyle? EndSound => null;
}
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 235 B

After

Width:  |  Height:  |  Size: 235 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 211 B

After

Width:  |  Height:  |  Size: 211 B

@@ -1,4 +1,5 @@
using System;
using CalamityMod.CalPlayer;
using CalamityMod.Items.Accessories;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@@ -22,7 +23,7 @@ namespace CalamityMod.Cooldowns
public static new string ID => "WulfrumRoverDriveDurability";
public override bool CanTickDown => !instance.player.Calamity().roverDrive || instance.timeLeft <= 0;
public override bool ShouldDisplay => instance.player.Calamity().roverDrive;
public override LocalizedText DisplayName => CalamityUtils.GetText($"UI.Cooldowns.{ID}");
public override LocalizedText DisplayName => GetText($"UI.Cooldowns.{ID}");
public override string Texture => "CalamityMod/Cooldowns/WulfrumRoverDriveActive";
public override string OutlineTexture => "CalamityMod/Cooldowns/WulfrumRoverDriveOutline";
public override string OverlayTexture => "CalamityMod/Cooldowns/WulfrumRoverDriveOverlay";
@@ -57,13 +58,13 @@ namespace CalamityMod.Cooldowns
Texture2D outline = Request<Texture2D>(OutlineTexture).Value;
Texture2D overlay = Request<Texture2D>(OverlayTexture).Value;
//Draw the outline
// Draw the outline
spriteBatch.Draw(outline, position, null, OutlineColor * opacity, 0, outline.Size() * 0.5f, scale, SpriteEffects.None, 0f);
//Draw the icon
// Draw the icon
spriteBatch.Draw(sprite, position, null, Color.White * opacity, 0, sprite.Size() * 0.5f, scale, SpriteEffects.None, 0f);
//Draw the small overlay
// 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);
@@ -89,7 +90,12 @@ namespace CalamityMod.Cooldowns
public override Color CooldownEndColor => Color.Lerp(ringColorLerpStart, ringColorLerpEnd, instance.Completion);
// Rover Drive shields are recharged as a side effect of the cooldown completing client side
public override void OnCompleted() => instance.player.Calamity().RoverDriveShieldDurability = RoverDrive.ShieldDurabilityMax;
public override void OnCompleted()
{
CalamityPlayer modPlayer = instance.player.Calamity();
if (modPlayer.roverDrive)
modPlayer.RoverDriveShieldDurability = RoverDrive.ShieldDurabilityMax;
}
public override SoundStyle? EndSound => null;
}
}