using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class MycorootProj : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Items/Weapons/Rogue/Mycoroot"; public override void SetDefaults() { Projectile.width = 12; Projectile.height = 12; Projectile.friendly = true; Projectile.penetrate = 1; Projectile.DamageType = RogueDamageClass.Instance; } public override void AI() { if (Main.rand.NextBool(4)) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 56, 0f, 0f); } Projectile.rotation = (float)Math.Atan2((double)Projectile.velocity.Y, (double)Projectile.velocity.X) + 0.785f; Projectile.alpha += 20; if (Projectile.alpha >= 255) { Projectile.Kill(); } Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0f / 255f, (255 - Projectile.alpha) * 0.35f / 255f, (255 - Projectile.alpha) * 0.5f / 255f); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { if (Projectile.Calamity().stealthStrike) SoundEngine.PlaySound(SoundID.NPCHit45, Projectile.position); } public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (Projectile.Calamity().stealthStrike) SoundEngine.PlaySound(SoundID.NPCHit45, Projectile.position); } public override bool PreDraw(ref Color lightColor) { Texture2D tex = ModContent.Request(Texture).Value; Main.EntitySpriteDraw(tex, Projectile.Center - Main.screenPosition, null, Projectile.GetAlpha(lightColor), Projectile.rotation, tex.Size() / 2f, Projectile.scale, SpriteEffects.None, 0); return false; } } }