Files
CalamityModPublic/Projectiles/Ranged/FungiOrb2.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

57 lines
2.2 KiB
C#

using Microsoft.Xna.Framework;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
namespace CalamityMod.Projectiles.Ranged
{
public class FungiOrb2 : ModProjectile, ILocalizedModType
{
public new string LocalizationCategory => "Projectiles.Ranged";
public override string Texture => "CalamityMod/Projectiles/Ranged/FungiOrb";
public override void SetDefaults()
{
Projectile.width = 12;
Projectile.height = 12;
Projectile.friendly = true;
Projectile.DamageType = DamageClass.Ranged;
Projectile.penetrate = 1;
Projectile.timeLeft = 180;
}
public override bool? CanHitNPC(NPC target) => Projectile.timeLeft < 150 && target.CanBeChasedBy(Projectile);
public override void AI()
{
//Rotation
Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt();
Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(90) * Projectile.direction;
Lighting.AddLight(Projectile.Center, new Vector3(0, 244, 252) * (1.2f / 255));
Projectile.localAI[0] += 1f;
if (Projectile.localAI[0] > 4f)
{
Vector2 dspeed = -Projectile.velocity * 0.5f;
int dust = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, DustID.BlueFairy, 0f, 0f, 100, default, 1f);
Main.dust[dust].noGravity = true;
Main.dust[dust].velocity = dspeed;
}
bool isHoming = false;
if (Projectile.timeLeft < 150)
{
isHoming = true;
CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 450f, 6.5f, 20f);
}
if (!isHoming)
Projectile.velocity.Y += 0.14f;
}
public override void OnKill(int timeLeft)
{
Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, DustID.BlueFairy, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f);
}
}
}