XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

DeathMod

【Terraria】DeathMod (now aka Soul Harvest)

公开
关注 0 Fork 0 Star 0
UTF-8
using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;

namespace SoulHarvest.Projectiles;

public class InfernalCrescentProjectile : ModProjectile
{
    public override void SetStaticDefaults()
    {
        ProjectileID.Sets.TrailCacheLength[Type] = 14;
        ProjectileID.Sets.TrailingMode[Type] = 2;
    }

    public override void SetDefaults()
    {
        Projectile.width = 42;
        Projectile.height = 42;
        Projectile.friendly = true;
        Projectile.tileCollide = false;
        Projectile.ignoreWater = true;
        Projectile.penetrate = 5;
        Projectile.timeLeft = 180;
        Projectile.DamageType = DamageClass.Melee;
        Projectile.netImportant = true;
    }

    public override void AI()
    {
        Projectile.localAI[0]++;
        if (Projectile.velocity.Length() < 23f + Projectile.ai[1] * 5f)
            Projectile.velocity *= 1.011f + Projectile.ai[1] * 0.004f;
        float curveDirection = System.Math.Sign(Projectile.ai[2] == 0f ? 1f : Projectile.ai[2]);
        Projectile.velocity = Projectile.velocity.RotatedBy(curveDirection * 0.0035f);
        if (Projectile.ai[0] > 0f && Projectile.localAI[0] > 18f)
        {
            NPC? target = ReaperProjectileHelper.FindTarget(Projectile, 520f);
            if (target is not null)
            {
                Vector2 desired = (target.Center - Projectile.Center).SafeNormalize(Vector2.UnitX) * Projectile.velocity.Length();
                Projectile.velocity = Vector2.Lerp(Projectile.velocity, desired, 0.026f + Projectile.ai[1] * 0.025f);
            }
        }
        Projectile.rotation = Projectile.velocity.ToRotation();
        if (!Main.dedServ)
        {
            Lighting.AddLight(Projectile.Center, new Vector3(0.85f, 0.28f, 0.02f));
            int dustCount = Projectile.ai[0] > 0f ? 2 : 1;
            for (int index = 0; index < dustCount; index++)
            {
                Dust dust = Dust.NewDustPerfect(Projectile.Center + Main.rand.NextVector2Circular(14f, 14f), DustID.Torch, -Projectile.velocity * 0.08f, 50, new Color(255, 120, 20), 1f + Projectile.ai[1] * 0.35f);
                dust.noGravity = true;
            }
        }
    }

    public override void OnKill(int timeLeft)
    {
        if (Main.dedServ)
            return;
        for (int index = 0; index < 12 + (int)(Projectile.ai[1] * 12f); index++)
        {
            Dust dust = Dust.NewDustPerfect(Projectile.Center, DustID.Torch, Main.rand.NextVector2Circular(4f, 4f), 40, new Color(255, 105, 15), 1.1f);
            dust.noGravity = true;
        }
    }

    public override bool PreDraw(ref Color lightColor) => ReaperProjectileHelper.DrawTrail(Projectile, new Color(255, 105, 10), scaleMultiplier: 1f + Projectile.ai[1] * 0.22f, copies: 12);
}