using Decimation.Content.Items.Misc.Souls;
using Decimation.Content.Items.Weapons.Bloodshot;
using Decimation.Lib.Items;
using Decimation.Lib.Util;
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace Decimation.Content.Items.Weapons
{
    internal class VampiricEdge : DecimationWeapon
    {
        private readonly int shootDelay = 72;
        private int _timeToShoot = 72;

        protected override string ItemName => "Vampiric Edge";
        protected override int Damages => 54;
        protected override string ProjectileName => "Tooth";

        protected override void InitWeapon()
        {
            item.width = 46;
            item.height = 52;
            item.crit = 6;
            item.knockBack = 4.5f;
            item.useTime = 20;
            item.useAnimation = 20;
            item.shootSpeed = 5f;
            item.value = Item.buyPrice(0, 3);
            item.rare = Rarity.Green.GetRarityValue();
            item.autoReuse = true;
        }

        public override void UpdateInventory(Player player)
        {
            if (_timeToShoot > 0) _timeToShoot--;
        }

        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY,
            ref int type, ref int damage, ref float knockBack)
        {
            if (_timeToShoot > 0) return false;

            _timeToShoot = shootDelay;

            return base.Shoot(player, ref position, ref speedX, ref speedY, ref type, ref damage, ref knockBack);
        }

        protected override ModRecipe GetRecipe()
        {
            ModRecipe recipe = GetNewModRecipe(this, 1, TileID.MythrilAnvil, true);

            recipe.AddIngredient(ItemID.BloodButcherer);
            recipe.AddIngredient(ModContent.ItemType<VampiricShiv>());
            recipe.AddIngredient(ModContent.ItemType<SoulofTime>(), 10);
            recipe.AddIngredient(ItemID.SoulofNight, 10);

            return recipe;
        }
    }
}