diff --git a/Items/Potions/Food/DeliciousMeat.cs b/Items/Potions/Food/DeliciousMeat.cs index 1dec5c6c86..c62b40d08a 100644 --- a/Items/Potions/Food/DeliciousMeat.cs +++ b/Items/Potions/Food/DeliciousMeat.cs @@ -1,6 +1,6 @@ using System; using CalamityMod.Effects; -using CalamityMod.Items.Tools; +using Terraria.Localization; using CalamityMod.Particles; using CalamityMod.Systems.Graphic.PixelationSystem; using CalamityMod.Utilities.Daybreak; @@ -19,8 +19,10 @@ namespace CalamityMod.Items.Potions.Food { private static Asset FadedStarRing; private static Asset BloomFlare; + private static int DeliciousMeatCooldown = CalamityUtils.MinutesToFrames(15); public new string LocalizationCategory => "Items.Potions"; + public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs((DeliciousMeatCooldown / 60).FramesToSeconds()); public override void Load() { @@ -56,11 +58,17 @@ namespace CalamityMod.Items.Potions.Food Item.UseSound = SoundID.Item2; Item.useStyle = ItemUseStyleID.EatFood; Item.buffType = BuffID.WellFed2; - Item.buffTime = CalamityUtils.MinutesToFrames(30); + Item.buffTime = CalamityUtils.MinutesToFrames(15); Item.useTurn = true; Item.consumable = false; } + public override bool CanUseItem(Player player) => player.GetModPlayer().deliciousMeatCooldown <= 0; + public override bool? UseItem(Player player) + { + player.GetModPlayer().deliciousMeatCooldown = DeliciousMeatCooldown; + return null; + } public override bool PreDrawInWorld(SpriteBatch spriteBatch, Color lightColor, Color alphaColor, ref float rotation, ref float scale, int whoAmI) { // Spawn some cute sparkles for added effect when dropped in the world. @@ -113,5 +121,34 @@ namespace CalamityMod.Items.Potions.Food return true; } + + public override void PostDrawInInventory(SpriteBatch spriteBatch, Vector2 position, Rectangle frame, Color drawColor, Color itemColor, Vector2 origin, float scale) + { + if (Main.LocalPlayer.GetModPlayer().deliciousMeatCooldown <= 0) + return; + + Vector2 barScale = new Vector2(1.25f, 1f); + var barBG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarBack").Value; + var barFG = ModContent.Request("CalamityMod/UI/MiscTextures/GenericBarFront").Value; + + Vector2 drawPos = position + new Vector2((frame.Width - barBG.Width * 0.95f) * scale, (frame.Height - 3f) * scale); + Rectangle frameCrop = new Rectangle(0, 0, (int)((1 - Main.LocalPlayer.GetModPlayer().deliciousMeatCooldown / (float)DeliciousMeatCooldown) * barFG.Width), barFG.Height); + Color colorBG = Color.Black; + Color colorFG = Color.White; + + spriteBatch.Draw(barBG, drawPos, null, colorBG, 0f, origin, scale * barScale, 0f, 0f); + spriteBatch.Draw(barFG, drawPos, frameCrop, colorFG * 0.8f, 0f, origin, scale * barScale, 0f, 0f); + } + } + + public class DeliciousMeatPlayer : ModPlayer + { + public int deliciousMeatCooldown = 0; + + public override void PostUpdateMiscEffects() + { + if (deliciousMeatCooldown > 0) + deliciousMeatCooldown--; + } } } diff --git a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson index 68c663ac6f..18cd1593dd 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Potions.hjson @@ -65,7 +65,7 @@ DeliciousMeat: { Tooltip: ''' {$CommonItemTooltip.MediumStats} - {$Common.NotConsumable} + {$Common.NotConsumable}, but takes {0} minutes to regenerate 'A blessed strip of pork that never seems to be entirely consumed...' ''' }