From 45641d30b8aacbbc3b471b49e70cb17687cb7db8 Mon Sep 17 00:00:00 2001 From: Dominic Date: Fri, 28 Oct 2022 20:12:44 -0500 Subject: [PATCH] Old Duke spike blackglow effect for visual clarity --- Projectiles/Enemy/TrilobiteSpike.cs | 13 ++++++++----- Utilities/ProjectileUtils.cs | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Projectiles/Enemy/TrilobiteSpike.cs b/Projectiles/Enemy/TrilobiteSpike.cs index 377ddb75d4..a245af79ef 100644 --- a/Projectiles/Enemy/TrilobiteSpike.cs +++ b/Projectiles/Enemy/TrilobiteSpike.cs @@ -1,8 +1,9 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; using Terraria; -using Terraria.ID; +using Terraria.GameContent; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Enemy @@ -41,10 +42,12 @@ namespace CalamityMod.Projectiles.Enemy public override bool PreDraw(ref Color lightColor) { - lightColor.R = (byte)(200 * Projectile.Opacity); - lightColor.G = (byte)(150 * Projectile.Opacity); - lightColor.B = (byte)(100 * Projectile.Opacity); - CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); + Texture2D texture = TextureAssets.Projectile[Projectile.type].Value; + Vector2 drawPosition = Projectile.position + Projectile.Size * 0.5f - Main.screenPosition; + Vector2 origin = texture.Size() * 0.5f; + + Projectile.DrawBackglow(Color.White, 4f); + Main.spriteBatch.Draw(texture, drawPosition, null, Color.White * Projectile.Opacity, Projectile.rotation, origin, Projectile.scale, 0, 0f); return false; } diff --git a/Utilities/ProjectileUtils.cs b/Utilities/ProjectileUtils.cs index fa02ddce21..06ce1e6b69 100644 --- a/Utilities/ProjectileUtils.cs +++ b/Utilities/ProjectileUtils.cs @@ -505,6 +505,23 @@ namespace CalamityMod return false; } + public static void DrawBackglow(this Projectile projectile, Color backglowColor, float backglowArea, Rectangle? frame = null) + { + Texture2D texture = TextureAssets.Projectile[projectile.type].Value; + + // Use a fallback for the frame. + frame ??= texture.Frame(1, Main.projFrames[projectile.type], 0, projectile.frame); + + Vector2 drawPosition = projectile.position + projectile.Size * 0.5f - Main.screenPosition; + Vector2 origin = frame.Value.Size() * 0.5f; + Color backAfterimageColor = projectile.GetAlpha(backglowColor with { A = 0 }); + for (int i = 0; i < 10; i++) + { + Vector2 drawOffset = (MathHelper.TwoPi * i / 10f).ToRotationVector2() * backglowArea; + Main.spriteBatch.Draw(texture, drawPosition + drawOffset, frame, backAfterimageColor, projectile.rotation, origin, projectile.scale, 0, 0f); + } + } + public static void ExplodeandDestroyTiles(Projectile projectile, int explosionRadius, bool checkExplosions, List tilesToCheck, List wallsToCheck) { int minTileX = (int)projectile.position.X / 16 - explosionRadius;