using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { public class PrismExplosionLarge : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override void SetDefaults() { Projectile.width = Projectile.height = 520; Projectile.friendly = true; Projectile.ignoreWater = false; Projectile.tileCollide = false; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = -1; Projectile.timeLeft = 150; Projectile.extraUpdates = 2; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 11; Projectile.scale = 0.35f; } public override void AI() { Lighting.AddLight(Projectile.Center, Color.White.ToVector3() * 1.5f); Projectile.frameCounter++; if (Projectile.frameCounter % 8 == 7) Projectile.frame++; if (Projectile.frame >= 18) Projectile.Kill(); Projectile.scale *= 1.0115f; Projectile.Opacity = Utils.GetLerpValue(5f, 36f, Projectile.timeLeft, true); } public override bool PreDraw(ref Color lightColor) { Texture2D texture = ModContent.Request(Texture).Value; Texture2D lightTexture = ModContent.Request("CalamityMod/ExtraTextures/SmallGreyscaleCircle").Value; Rectangle frame = texture.Frame(3, 6, Projectile.frame / 6, Projectile.frame % 6); Vector2 drawPosition = Projectile.Center - Main.screenPosition; Vector2 origin = frame.Size() * 0.5f; for (int i = 0; i < 36; i++) { Vector2 lightDrawPosition = drawPosition + (MathHelper.TwoPi * i / 36f + Main.GlobalTimeWrappedHourly * 5f).ToRotationVector2() * Projectile.scale * 20f; Color lightBurstColor = CalamityUtils.MulticolorLerp(Projectile.timeLeft / 144f, CalamityUtils.ExoPalette); lightBurstColor = Color.Lerp(lightBurstColor, Color.White, 0.4f) * Projectile.Opacity * 0.04f; lightBurstColor.A = 0; Main.EntitySpriteDraw(lightTexture, lightDrawPosition, null, lightBurstColor, 0f, lightTexture.Size() * 0.5f, Projectile.scale * 4.5f, SpriteEffects.None, 0); } Main.EntitySpriteDraw(texture, drawPosition, frame, Color.White, 0f, origin, 1.6f, SpriteEffects.None, 0); return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) => target.AddBuff(ModContent.BuffType(), 300); public override void OnHitPlayer(Player target, Player.HurtInfo info) => target.AddBuff(ModContent.BuffType(), 300); } }