using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class ChargedBlast2 : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override string Texture => "CalamityMod/Projectiles/LaserProj"; public override void SetDefaults() { Projectile.width = 5; Projectile.height = 5; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 3; Projectile.extraUpdates = 2; Projectile.alpha = 255; Projectile.timeLeft = 200; } public override void AI() { if (Projectile.alpha > 0) { Projectile.alpha -= 25; } if (Projectile.alpha < 0) { Projectile.alpha = 0; } Lighting.AddLight((int)Projectile.Center.X / 16, (int)Projectile.Center.Y / 16, 0f, 0.3f, 0.7f); float num55 = 30f; float num56 = 1f; if (Projectile.ai[1] == 0f) { Projectile.localAI[0] += num56; if (Projectile.localAI[0] > num55) { Projectile.localAI[0] = num55; } } else { Projectile.localAI[0] -= num56; if (Projectile.localAI[0] <= 0f) { Projectile.Kill(); return; } } } public override Color? GetAlpha(Color lightColor) => new Color(100, 100, 255, 0); public override bool PreDraw(ref Color lightColor) => Projectile.DrawBeam(100f, 3f, lightColor); public override bool OnTileCollide(Vector2 oldVelocity) { SoundEngine.PlaySound(SoundID.Item10, Projectile.position); Projectile.penetrate--; if (Projectile.penetrate <= 0) { Projectile.Kill(); } else { if (Projectile.velocity.X != oldVelocity.X) { Projectile.velocity.X = -oldVelocity.X; } if (Projectile.velocity.Y != oldVelocity.Y) { Projectile.velocity.Y = -oldVelocity.Y; } } return false; } public override void Kill(int timeLeft) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 160, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.immune[Projectile.owner] = 3; } } }