using Decimation.Content.Buffs.Buffs;
using Decimation.Content.Dusts;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Decimation.Content.Buffs.Debuffs;
using Terraria;
using Terraria.DataStructures;
using Terraria.ID;
using Terraria.ModLoader;

namespace Decimation.Content.Projectiles
{
   internal class BloodBeam : DecimationProjectile
    {
        public override string Texture => "Terraria/Projectile_" + ProjectileID.CursedFlameHostile;

        protected override void Init()
        {
            projectile.width = 26;
            projectile.height = 26;
            projectile.aiStyle = -1;
            projectile.penetrate = -1;
            projectile.alpha = 255;
            projectile.timeLeft = 40;
            projectile.tileCollide = false;
            projectile.ignoreWater = true;
            Damages = 25;
            projectile.hostile = true;
            projectile.friendly = false;
        }

        public override void AI()
        {
            projectile.velocity.Y += (60 - projectile.timeLeft) * 0.005f;

            Dust.NewDust(projectile.position, 26, 26, ModContent.DustType<Blood>());
        }

        public override void OnHitPlayer(Player target, int damage, bool crit)
        {
            if (Main.expertMode)
                target.AddBuff(ModContent.BuffType<Slimed>(), 600);

            int damages = Main.rand.Next(5, 11);
            target.Hurt(PlayerDeathReason.LegacyDefault(), damages, 0);

            NPC bloodshotEye = Main.npc[(int)projectile.ai[0]];
            bloodshotEye.life += damages;
            bloodshotEye.HealEffect(damages);
        }
    }
}
