64 lines
2.1 KiB
C#
64 lines
2.1 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Melee
|
|
{
|
|
public class MirrorBlast : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Melee";
|
|
public override void SetStaticDefaults()
|
|
{
|
|
ProjectileID.Sets.TrailCacheLength[Projectile.type] = 10;
|
|
ProjectileID.Sets.TrailingMode[Projectile.type] = 1;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 12;
|
|
Projectile.height = 12;
|
|
Projectile.friendly = true;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.DamageType = DamageClass.Melee;
|
|
Projectile.penetrate = 1;
|
|
Projectile.timeLeft = 300;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
int playerOwner = (int)Player.FindClosest(Projectile.Center, 1, 1);
|
|
Projectile.ai[1] += 1f;
|
|
if (Projectile.ai[1] < 110f && Projectile.ai[1] > 30f)
|
|
{
|
|
float scaleFactor = Projectile.velocity.Length();
|
|
Vector2 projDirection = Main.player[playerOwner].Center - Projectile.Center;
|
|
projDirection.Normalize();
|
|
projDirection *= scaleFactor;
|
|
Projectile.velocity = (Projectile.velocity * 24f + projDirection) / 25f;
|
|
Projectile.velocity.Normalize();
|
|
Projectile.velocity *= scaleFactor;
|
|
}
|
|
|
|
if (Projectile.velocity.Length() < 18f)
|
|
{
|
|
Projectile.velocity *= 1.02f;
|
|
}
|
|
|
|
Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2;
|
|
|
|
Lighting.AddLight(Projectile.Center, 0f, 0.35f, 0.35f);
|
|
}
|
|
|
|
public override bool PreDraw(ref Color lightColor)
|
|
{
|
|
if (Projectile.timeLeft > 295)
|
|
return false;
|
|
|
|
CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 2);
|
|
return false;
|
|
}
|
|
}
|
|
}
|