61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Terraria;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Ranged
|
|
{
|
|
public class MagnomalyAura : ModProjectile, ILocalizedModType
|
|
{
|
|
public new string LocalizationCategory => "Projectiles.Ranged";
|
|
public override string Texture => "CalamityMod/Projectiles/InvisibleProj";
|
|
|
|
private int radius = 100;
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
Projectile.DamageType = DamageClass.Ranged;
|
|
Projectile.usesIDStaticNPCImmunity = true;
|
|
Projectile.idStaticNPCHitCooldown = 10;
|
|
Projectile.width = 200;
|
|
Projectile.height = 200;
|
|
Projectile.friendly = true;
|
|
Projectile.tileCollide = false;
|
|
Projectile.penetrate = -1;
|
|
Projectile.alpha = 255;
|
|
Projectile.ignoreWater = true;
|
|
Projectile.timeLeft = 300;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
Projectile parent = Main.projectile[0];
|
|
bool active = false;
|
|
for (int i = 0; i < Main.projectile.Length; i++)
|
|
{
|
|
Projectile p = Main.projectile[i];
|
|
if (p.identity == Projectile.ai[0] && p.active && p.type == ModContent.ProjectileType<MagnomalyRocket>())
|
|
{
|
|
parent = p;
|
|
active = true;
|
|
}
|
|
}
|
|
|
|
if (active)
|
|
{
|
|
Projectile.Center = parent.Center;
|
|
}
|
|
else
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
|
|
if (!parent.active)
|
|
{
|
|
Projectile.Kill();
|
|
}
|
|
}
|
|
|
|
public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, radius, targetHitbox);
|
|
}
|
|
}
|