Files
CalamityModPublic/Projectiles/Summon/EnergyOrb.cs
T
tomat 67bceff6e7 Initial dotnet format pass.
This commit formats the entire codebase according to `dotnet format` and its limited understanding of our provided `.editorconfig`.
2024-02-28 21:49:50 -08:00

42 lines
1.6 KiB
C#

using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Summon
{
public class EnergyOrb : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Summon";
public override string Texture => "CalamityMod/Projectiles/Magic/BlueBubble";
public override void SetDefaults()
{
Projectile.width = 14;
Projectile.height = 14;
Projectile.alpha = 100;
Projectile.friendly = true;
Projectile.penetrate = 1;
Projectile.tileCollide = false;
Projectile.timeLeft = 200;
Projectile.DamageType = DamageClass.Summon;
}
public override void AI()
{
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 4f)
{
int dust = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, DustID.Firework_Blue, 0f, 0f, 100, default, 1f);
if (!Main.rand.NextBool(6))
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity *= 0f;
}
NPC potentialTarget = Projectile.Center.MinionHoming(400f, Main.player[Projectile.owner]);
if (potentialTarget != null)
Projectile.velocity = (Projectile.velocity * 20f + Projectile.SafeDirectionTo(potentialTarget.Center) * 10f) / 21f;
}
public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(BuffID.Electrified, 120);
}
}