84 lines
2.9 KiB
C#
84 lines
2.9 KiB
C#
using CalamityMod.CalPlayer;
|
|
using CalamityMod.Items.Materials;
|
|
using CalamityMod.Rarities;
|
|
using CalamityMod.Tiles.Furniture.CraftingStations;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.Audio;
|
|
using Terraria.ID;
|
|
using Terraria.Localization;
|
|
using Terraria.ModLoader;
|
|
using System.Linq;
|
|
using System.Collections.Generic;
|
|
|
|
namespace CalamityMod.Items.PermanentBoosters
|
|
{
|
|
public class Dragonfruit : ModItem, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Items.Misc";
|
|
|
|
public const int LifeBoost = 25;
|
|
public override LocalizedText Tooltip => base.Tooltip.WithFormatArgs(LifeBoost);
|
|
|
|
public static readonly SoundStyle UseSound = new("CalamityMod/Sounds/Item/DragonfruitConsume");
|
|
public override void SetStaticDefaults()
|
|
{
|
|
// For some reason Life/Mana boosting items are in this set (along with Magic Mirror+)
|
|
ItemID.Sets.SortingPriorityBossSpawns[Type] = 20; // Life Fruit
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Item.width = 32;
|
|
Item.height = 32;
|
|
Item.useAnimation = 30;
|
|
Item.useTime = 30;
|
|
Item.useStyle = ItemUseStyleID.HoldUp;
|
|
Item.UseSound = UseSound;
|
|
Item.consumable = true;
|
|
Item.rare = ModContent.RarityType<Violet>();
|
|
}
|
|
|
|
public override bool CanUseItem(Player player) => player.ConsumedLifeFruit == Player.LifeFruitMax;
|
|
|
|
public override bool? UseItem(Player player)
|
|
{
|
|
CalamityPlayer modPlayer = player.Calamity();
|
|
if (player.itemAnimation > 0 && player.itemTime == 0)
|
|
{
|
|
player.itemTime = Item.useTime;
|
|
if (modPlayer.dFruit)
|
|
{
|
|
string key = "Mods.CalamityMod.Misc.DragonfruitText";
|
|
Color messageColor = Color.Cyan;
|
|
CalamityUtils.DisplayLocalizedText(key, messageColor);
|
|
return false;
|
|
}
|
|
|
|
player.UseHealthMaxIncreasingItem(LifeBoost);
|
|
modPlayer.dFruit = true;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public override void ModifyTooltips(List<TooltipLine> list)
|
|
{
|
|
TooltipLine line = list.FirstOrDefault(x => x.Mod == "Terraria" && x.Name == "Tooltip1");
|
|
|
|
if (line != null && Main.LocalPlayer.Calamity().dFruit)
|
|
line.Text += "\n" + CalamityUtils.GetTextValue("Misc.GenericConsumedText");
|
|
}
|
|
|
|
public override void AddRecipes()
|
|
{
|
|
CreateRecipe().
|
|
AddIngredient(ItemID.LifeFruit, 5).
|
|
AddIngredient(ItemID.FragmentSolar, 15).
|
|
AddIngredient<YharonSoulFragment>(5).
|
|
AddIngredient<AscendantSpiritEssence>().
|
|
AddTile<CosmicAnvil>().
|
|
Register();
|
|
}
|
|
}
|
|
}
|