using Decimation.Lib.Projectile;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Terraria.ModLoader;

namespace Decimation.Content.Projectiles.DuneWyrm
{
    class AncientTombCrawlerHead : AncientTombCrawler
    {
        public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerHead";

        protected override void Init()
        {
            base.Init();
            
            projectile.damage = 50;
            projectile.width = 38;
            projectile.height = 38;
            projectile.minionSlots = 1f;
        }

        public override void InitWorm()
        {
            base.InitWorm();
            Head = true;
        }
    }

    class AncientTombCrawlerBody : AncientTombCrawler
    {
        public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerBody";

        protected override void Init()
        {
            base.Init();

            projectile.width = 24;
            projectile.height = 24;
            projectile.damage = 35;
        }
    }

    class AncientTombCrawlerTail : AncientTombCrawler
    {
        public override string Texture => "Decimation/Content/NPCs/DuneWyrm/AncientTombCrawler/AncientTombCrawlerTail";

        protected override void Init()
        {
            base.Init();

            projectile.width = 20;
            projectile.height = 20;
            projectile.damage = 25;
        }

        public override void InitWorm()
        {
            base.InitWorm();
            Tail = true;
        }
    }

    public abstract class AncientTombCrawler : WormProjectile
    {
        protected override void Init()
        {
            projectile.aiStyle = -1;
            projectile.penetrate = -1;
            projectile.light = 1f;
            projectile.tileCollide = false;
            projectile.ignoreWater = true;
            projectile.netImportant = true;
            projectile.timeLeft = int.MaxValue;
            projectile.hostile = false;
            projectile.friendly = true;
        }

        public override void InitWorm()
        {
            MinLength = 8;
            MaxLength = 8;
            TailType = ModContent.ProjectileType<AncientTombCrawlerTail>();
            BodyType = ModContent.ProjectileType<AncientTombCrawlerBody>();
            HeadType = ModContent.ProjectileType<AncientTombCrawlerHead>();
            Speed = 8f;
            TurnSpeed = 0.1f;
        }

        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Draw(Texture.Replace("Decimation/", ""), spriteBatch, lightColor);
            
            return false;
        }
    }
}