80 lines
2.9 KiB
C#
80 lines
2.9 KiB
C#
using System;
|
|
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.DraedonsArsenal
|
|
{
|
|
public class GaussFlux : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Misc";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
public float Time
|
|
{
|
|
get => Projectile.ai[0];
|
|
set => Projectile.ai[0] = value;
|
|
}
|
|
public NPC Target
|
|
{
|
|
get => Main.npc[(int)Projectile.ai[1]];
|
|
set => Projectile.ai[1] = value.whoAmI;
|
|
}
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.width = 16;
|
|
Projectile.height = 16;
|
|
Projectile.friendly = true;
|
|
Projectile.DamageType = DamageClass.Melee;
|
|
Projectile.penetrate = -1;
|
|
Projectile.timeLeft = 180;
|
|
Projectile.usesIDStaticNPCImmunity = true;
|
|
Projectile.idStaticNPCHitCooldown = 10;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Lighting.AddLight(Projectile.Center, Color.Lime.ToVector3());
|
|
if (!Target.active)
|
|
{
|
|
Projectile.Kill();
|
|
return;
|
|
}
|
|
Projectile.Center = Target.Center;
|
|
if (!Main.dedServ)
|
|
{
|
|
if (Time == 0)
|
|
{
|
|
for (int i = 0; i < 60; i++)
|
|
{
|
|
Dust dust = Dust.NewDustPerfect(Target.Center, 261);
|
|
dust.color = Utils.SelectRandom(Main.rand, Color.Yellow, Color.YellowGreen);
|
|
dust.velocity = Main.rand.NextVector2Circular(20f, 20f);
|
|
dust.scale = 2f;
|
|
dust.noGravity = true;
|
|
}
|
|
}
|
|
for (int i = 0; i < 7; i++)
|
|
{
|
|
for (int arcIndex = 0; arcIndex < 6; arcIndex++)
|
|
{
|
|
float offsetAngle = MathHelper.ToRadians(1080f) * i / 18f;
|
|
offsetAngle += Time / 10f;
|
|
float scale = 1.4f + (float)Math.Cos(i / 7f * MathHelper.TwoPi + Time / 30f) * 0.3f;
|
|
scale *= MathHelper.Lerp(1f, 0.4f, arcIndex / 6f);
|
|
Vector2 offset = Target.Size.RotatedBy(offsetAngle) * 0.5f;
|
|
offset += (arcIndex * MathHelper.TwoPi / 6f + Time / 20f).ToRotationVector2() * 6f * arcIndex;
|
|
|
|
Dust dust = Dust.NewDustPerfect(Target.Center + offset, 261);
|
|
dust.color = Utils.SelectRandom(Main.rand, Color.Yellow, Color.YellowGreen);
|
|
dust.velocity = Vector2.Zero;
|
|
dust.scale = scale;
|
|
dust.noGravity = true;
|
|
}
|
|
}
|
|
}
|
|
Time++;
|
|
}
|
|
}
|
|
}
|