using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { public class SupremeCataclysmFist : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Boss"; public ref float Time => ref Projectile.ai[0]; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 4; } public override void SetDefaults() { Projectile.width = Projectile.height = 44; Projectile.hostile = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.penetrate = -1; Projectile.timeLeft = 1200; Projectile.Opacity = 0f; CooldownSlot = ImmunityCooldownID.Bosses; } public override void AI() { // Fly in a sinusoidal wave. Projectile.velocity.Y = (float)Math.Sin(Time / 5D) * 5f; // Decide frames. Projectile.frameCounter++; Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Projectile.type]; // Fade in and handle visuals. Projectile.Opacity = Utils.GetLerpValue(0f, 12f, Projectile.timeLeft, true) * Utils.GetLerpValue(1200f, 1188f, Projectile.timeLeft, true); Projectile.spriteDirection = (Projectile.velocity.X > 0f).ToDirectionInt(); Time++; // Emit light. Lighting.AddLight(Projectile.Center, 0.5f * Projectile.Opacity, 0f, 0f); } public override bool PreDraw(ref Color lightColor) { lightColor.R = (byte)(255 * Projectile.Opacity); SpriteEffects direction = Projectile.spriteDirection == -1 ? SpriteEffects.FlipHorizontally : SpriteEffects.None; Texture2D texture = ModContent.Request(Texture).Value; if (Projectile.ai[1] == 1f) texture = ModContent.Request("CalamityMod/Projectiles/Boss/SupremeCataclysmFistAlt").Value; Vector2 drawPosition = Projectile.Center - Main.screenPosition + Vector2.UnitY * Projectile.gfxOffY; drawPosition.X -= Math.Sign(Projectile.velocity.X) * 40f; Rectangle frame = texture.Frame(1, Main.projFrames[Projectile.type], 0, Projectile.frame); Main.EntitySpriteDraw(texture, drawPosition, frame, Projectile.GetAlpha(lightColor), Projectile.rotation, frame.Size() * 0.5f, Projectile.scale, direction, 0); return false; } public override bool CanHitPlayer(Player target) => Projectile.Opacity >= 1f; public override void OnHitPlayer(Player target, Player.HurtInfo info) { if (info.Damage <= 0 || Projectile.Opacity != 1f) return; target.AddBuff(ModContent.BuffType(), 120, true); } } }