From 2e562df4508a1e5a7a502dcbb9b186dd6b185060 Mon Sep 17 00:00:00 2001 From: Altixal <73398287+Altixal@users.noreply.github.com> Date: Mon, 3 Jun 2024 06:18:42 +0700 Subject: [PATCH] Explosion uses new PrimitiveTrail --- .../Mods.CalamityMod.Items.Placeables.hjson | 2 +- ...ods.CalamityMod.Projectiles.Typeless.hjson | 2 +- .../Typeless/AuricLandMineExplosion.cs | 35 ++++++------------- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson index 5818f5146c..6ac59e1b4a 100644 --- a/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson +++ b/Localization/en-US/Mods.CalamityMod.Items.Placeables.hjson @@ -1423,7 +1423,7 @@ AuricDisplay: { AuricLandMine: { DisplayName: Auric Land Mine - Tooltip: "Explodes when stepped on..." + Tooltip: Explodes when stepped on... } AuricPanel: { diff --git a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson index baa9642dd0..359c4e089f 100644 --- a/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson +++ b/Localization/en-US/Mods.CalamityMod.Projectiles.Typeless.hjson @@ -134,4 +134,4 @@ WulfrumDiggingTurtleProjectile.DisplayName: Digging Turtle WulfrumHook.DisplayName: Wulfrum Slingshot WulfrumLureSignal.DisplayName: Signal YanmeisKnifeSlash.DisplayName: Yanmei's Knife -YellowLabSeeker.DisplayName: Seeking Mechanism \ No newline at end of file +YellowLabSeeker.DisplayName: Seeking Mechanism diff --git a/Projectiles/Typeless/AuricLandMineExplosion.cs b/Projectiles/Typeless/AuricLandMineExplosion.cs index dbf9987360..efffc49073 100644 --- a/Projectiles/Typeless/AuricLandMineExplosion.cs +++ b/Projectiles/Typeless/AuricLandMineExplosion.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using CalamityMod.Graphics.Primitives; using CalamityMod.NPCs.ExoMechs.Ares; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -7,6 +8,7 @@ using Terraria.Audio; using Terraria.Graphics.Shaders; using Terraria.ID; using Terraria.ModLoader; + namespace CalamityMod.Projectiles.Typeless { public class AuricLandMineExplosion : ModProjectile, ILocalizedModType @@ -81,41 +83,24 @@ namespace CalamityMod.Projectiles.Typeless target.velocity += yeetVec * (target.noKnockback ? 20f : 40f); return true; } - public PrimitiveTrail LightningDrawer; - public PrimitiveTrail LightningBackgroundDrawer; - internal float WidthFunction(float completionRatio) - { - return MathHelper.Clamp(completionRatio * 2, 0.4f, 1f); - } + internal float WidthFunction(float completionRatio) => MathHelper.Clamp(completionRatio * 2, 0.4f, 1f); + internal Color ColorFunction(float completionRatio) => new Color(174, 227, 244); - internal Color ColorFunction(float completionRatio) - { - return new Color(174, 227, 244); - } internal float BackgroundWidthFunction(float completionRatio) => WidthFunction(completionRatio) * 2f; - - internal Color BackgroundColorFunction(float completionRatio) - { - return new Color(92, 144, 245) * 0.6f; - } + internal Color BackgroundColorFunction(float completionRatio) => new Color(92, 144, 245) * 0.6f; public override bool PreDraw(ref Color lightColor) { - Main.spriteBatch.EnterShaderRegion(); - if (LightningDrawer is null) - LightningDrawer = new PrimitiveTrail(WidthFunction, ColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:TeslaTrail"]); - if (LightningBackgroundDrawer is null) - LightningBackgroundDrawer = new PrimitiveTrail(BackgroundWidthFunction, BackgroundColorFunction, PrimitiveTrail.RigidPointRetreivalFunction, GameShaders.Misc["CalamityMod:TeslaTrail"]); - GameShaders.Misc["CalamityMod:TeslaTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ZapTrail")); - - if (lightningTrails.Count <= 0) return false; + + Main.spriteBatch.EnterShaderRegion(); + GameShaders.Misc["CalamityMod:TeslaTrail"].SetShaderTexture(ModContent.Request("CalamityMod/ExtraTextures/Trails/ZapTrail")); foreach (List points in lightningTrails) { - LightningBackgroundDrawer.Draw(points, -Main.screenPosition, 60); - LightningDrawer.Draw(points, -Main.screenPosition, 60); + PrimitiveRenderer.RenderTrail(points, new(WidthFunction, ColorFunction, (_) => Vector2.Zero, shader: GameShaders.Misc["CalamityMod:TeslaTrail"]), 60); + PrimitiveRenderer.RenderTrail(points, new(BackgroundWidthFunction, BackgroundColorFunction, (_) => Vector2.Zero, shader: GameShaders.Misc["CalamityMod:TeslaTrail"]), 60); } Main.spriteBatch.ExitShaderRegion();