From 4b962167cf46b47ef6d7b4a89d9ee2e1e0de96dd Mon Sep 17 00:00:00 2001 From: fryzahh Date: Sun, 9 Nov 2025 16:36:38 -0400 Subject: [PATCH] Pixelated dust variants * Added the following pixelated variants for their respective ModDust types: * DiamondDustPixelated * SquareDustPixelated * SquashDustPixelated * SquashDustHollowPixelated * SquashDustTileTouchPixelated * UnstableDustPixelated * VoidDustPixelated * VoidDustInvertedPixelated * Added missing documentation comment for the new "pixelate" parameter in GeneralParticleHandler.SpawnParticle. --- Dusts/DiamondDust.cs | 52 ++++++++++++++--- Dusts/LightDust.cs | 21 +++---- Dusts/SquareDust.cs | 47 ++++++++++++--- Dusts/SquashDust.cs | 55 +++++++++++++++--- Dusts/SquashDustHollow.cs | 51 ++++++++++++++--- Dusts/SquashDustTileTouch.cs | 32 +++++++---- Dusts/UnstableDust.cs | 47 ++++++++++++--- Dusts/VoidDust.cs | 49 ++++++++++++++-- Dusts/VoidDustInverted.cs | 57 +++++++++++++++---- Particles/GeneralParticleHandler.cs | 7 +-- .../PixelationSystem/PixelationManager.cs | 4 +- 11 files changed, 336 insertions(+), 86 deletions(-) diff --git a/Dusts/DiamondDust.cs b/Dusts/DiamondDust.cs index 501f5b7643..3b34857b02 100644 --- a/Dusts/DiamondDust.cs +++ b/Dusts/DiamondDust.cs @@ -1,5 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -7,7 +9,16 @@ namespace CalamityMod.Dusts { public class DiamondDust : ModDust { + public static Asset GlowDiamond { get; private set; } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (!Main.dedServ) + GlowDiamond = ModContent.Request("CalamityMod/Particles/SquareRotated"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -38,26 +49,51 @@ namespace CalamityMod.Dusts return false; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/SquareRotated").Value; - // dust.fadeIn is used to determine how intense the squash is, 1 is no squash, 0 is normal squash float squashLerp = Utils.GetLerpValue(10, 25, dust.fadeIn, true); Vector2 squash = new Vector2(MathHelper.Lerp(1, 0.3f, squashLerp), MathHelper.Lerp(1, 7f, squashLerp)); // Glow Orb - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); if (!dust.noLight) { for (int i = 0; i < 2; i++) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha) * (i == 0 ? 1f : 0.7f), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.08f * (i == 0 ? 0.7f : 1), SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha) * (i == 0 ? 1f : 0.7f), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.08f * (i == 0 ? 0.7f : 1), SpriteEffects.None, 0); } return false; } } + + public class DiamondDustPixelated : DiamondDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + public static void DrawPixelated(Dust dust) + { + // dust.fadeIn is used to determine how intense the squash is, 1 is no squash, 0 is normal squash + float squashLerp = Utils.GetLerpValue(10, 25, dust.fadeIn, true); + Vector2 squash = new Vector2(MathHelper.Lerp(1, 0.3f, squashLerp), MathHelper.Lerp(1, 7f, squashLerp)); + + // Glow Orb + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.spriteBatch.Draw(GlowDiamond.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha) * (i == 0 ? 1f : 0.7f), dust.rotation, GlowDiamond.Size() * 0.5f, squash * dust.scale * 0.08f * (i == 0 ? 0.7f : 1), SpriteEffects.None, 0); + } + } + } } diff --git a/Dusts/LightDust.cs b/Dusts/LightDust.cs index 3da334e73c..6e5338861a 100644 --- a/Dusts/LightDust.cs +++ b/Dusts/LightDust.cs @@ -11,9 +11,9 @@ namespace CalamityMod.Dusts { public class LightDust : ModDust { - public static Asset SolidCircle; + public static Asset SolidCircle { get; private set; } - public static Asset BloomCircle; + public static Asset BloomCircle { get; private set; } public override void Load() { @@ -47,15 +47,12 @@ namespace CalamityMod.Dusts public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - // Glow Orb - Main.EntitySpriteDraw(BloomCircle.Value, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(BloomCircle.Value, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); if (!dust.noLight) - Main.EntitySpriteDraw(SolidCircle.Value, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); - + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); return false; } } @@ -72,14 +69,12 @@ namespace CalamityMod.Dusts private static void DrawPixelated(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - // Glow Orb - Main.spriteBatch.Draw(BloomCircle.Value, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.spriteBatch.Draw(BloomCircle.Value, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); if (!dust.noLight) - Main.spriteBatch.Draw(SolidCircle.Value, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); } } } diff --git a/Dusts/SquareDust.cs b/Dusts/SquareDust.cs index 054b05ad37..7c25502b6a 100644 --- a/Dusts/SquareDust.cs +++ b/Dusts/SquareDust.cs @@ -1,6 +1,8 @@ using System; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,7 +10,16 @@ namespace CalamityMod.Dusts { public class SquareDust : ModDust { + public static Asset GlowSquare { get; private set; } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (!Main.dedServ) + GlowSquare = ModContent.Request("CalamityMod/Particles/GlowSquareParticleThick"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -42,22 +53,44 @@ namespace CalamityMod.Dusts } public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/GlowSquareParticleThick").Value; - Vector2 squash = Vector2.One; // Glow Orb - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0f); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.095f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.095f, SpriteEffects.None, 0f); if (!dust.noLight) { for (int i = 0; i < 2; i++) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0f); } return false; } } + + public class SquareDustPixelated : SquareDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Vector2 squash = Vector2.One; + + // Glow Orb + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0f); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.095f, SpriteEffects.None, 0f); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.spriteBatch.Draw(GlowSquare.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowSquare.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0f); + } + } + } } diff --git a/Dusts/SquashDust.cs b/Dusts/SquashDust.cs index 5894cedb1b..8adfb2beaa 100644 --- a/Dusts/SquashDust.cs +++ b/Dusts/SquashDust.cs @@ -1,5 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -7,7 +9,21 @@ namespace CalamityMod.Dusts { public class SquashDust : ModDust { + public static Asset SolidCircle { get; private set; } + + public static Asset BloomCircle { get; private set; } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (Main.dedServ) + return; + + SolidCircle = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle"); + BloomCircle = ModContent.Request("CalamityMod/Particles/BloomCircle"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -37,24 +53,45 @@ namespace CalamityMod.Dusts return false; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - Texture2D solidCenter = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - Vector2 squash = new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)); // Glow Orb - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); if (!dust.noLight) { - Main.EntitySpriteDraw(solidCenter, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, solidCenter.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); } return false; } } + + public class SquashDustPixelated : SquashDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Vector2 squash = new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)); + + // Glow Orb + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); + if (!dust.noLight) + { + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + } + } + } } diff --git a/Dusts/SquashDustHollow.cs b/Dusts/SquashDustHollow.cs index 9378128784..ec82d5aa67 100644 --- a/Dusts/SquashDustHollow.cs +++ b/Dusts/SquashDustHollow.cs @@ -1,5 +1,7 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -7,7 +9,16 @@ namespace CalamityMod.Dusts { public class SquashDustHollow : ModDust { + public static Asset BloomRing { get; private set; } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (!Main.dedServ) + BloomRing = ModContent.Request("CalamityMod/Particles/BloomRing"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -36,25 +47,49 @@ namespace CalamityMod.Dusts return false; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomRing").Value; - // dust.fadeIn is used to determine how intense the squash is, 1 is no squash, 0 is normal squash Vector2 squash = Vector2.Lerp(new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)), Vector2.One, dust.fadeIn); // Glow Orb - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); if (!dust.noLight) { for (int i = 0; i < 2; i++) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); } return false; } } + + public class SquashDustHollowPixelated : SquashDustHollow + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + // dust.fadeIn is used to determine how intense the squash is, 1 is no squash, 0 is normal squash + Vector2 squash = Vector2.Lerp(new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)), Vector2.One, dust.fadeIn); + + // Glow Orb + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.2f) with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.09f, SpriteEffects.None, 0); + if (!dust.noLight) + { + for (int i = 0; i < 2; i++) + Main.EntitySpriteDraw(BloomRing.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.4f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomRing.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + } + } + } } diff --git a/Dusts/SquashDustTileTouch.cs b/Dusts/SquashDustTileTouch.cs index 0884d87cb4..8b994b462d 100644 --- a/Dusts/SquashDustTileTouch.cs +++ b/Dusts/SquashDustTileTouch.cs @@ -1,13 +1,15 @@ -using Microsoft.Xna.Framework; +using CalamityMod.Systems.Graphic.PixelationSystem; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Dusts { - public class SquashDustTileTouch : ModDust + public class SquashDustTileTouch : SquashDust { public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -16,12 +18,14 @@ namespace CalamityMod.Dusts public override bool Update(Dust dust) { bool touchedTiles = false; - int size = (int)(2); + int size = 2; + if (Collision.SolidCollision(dust.position, size, size)) { touchedTiles = true; dust.velocity = Vector2.Zero; } + float fadeSpeed = (dust.fadeIn + 1); // For this dust, fadeIn is used to increase the power of gravity if it's active, otherwise it makes it's lifetime change dust.rotation = dust.velocity.ToRotation() + MathHelper.PiOver2; dust.velocity *= 0.96f; @@ -45,24 +49,30 @@ namespace CalamityMod.Dusts return false; } + } + + public class SquashDustTileTouchPixelated : SquashDustTileTouch + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - Texture2D solidCenter = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + private static void DrawPixelated(Dust dust) + { Vector2 squash = new Vector2(Utils.Remap(dust.velocity.Length(), 2, 7, 1, 0.5f), Utils.Remap(dust.velocity.Length(), 2, 7, 1, 2.5f)); // Glow Orb - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, squash * dust.scale * 0.04f, SpriteEffects.None, 0); if (!dust.noLight) { - Main.EntitySpriteDraw(solidCenter, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, solidCenter.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, squash * dust.scale * 0.075f, SpriteEffects.None, 0); } - return false; } } } diff --git a/Dusts/UnstableDust.cs b/Dusts/UnstableDust.cs index ee9cbf0fce..82f42fbfb5 100644 --- a/Dusts/UnstableDust.cs +++ b/Dusts/UnstableDust.cs @@ -1,6 +1,8 @@ using System; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,7 +10,16 @@ namespace CalamityMod.Dusts { public class UnstableDust : ModDust { + public static Asset GlowStar { get; private set; } + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override void Load() + { + if (!Main.dedServ) + GlowStar = ModContent.Request("CalamityMod/Particles/FullStar"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -41,23 +52,45 @@ namespace CalamityMod.Dusts return false; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/FullStar").Value; - Vector2 squash = new Vector2(0.4f, 1); float texScaling = 6; - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.1f * texScaling, SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.1f * texScaling, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.04f * texScaling, SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.04f * texScaling, SpriteEffects.None, 0); if (!dust.noLight) { - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, squash * dust.scale * 0.025f * texScaling, SpriteEffects.None, 0); + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.025f * texScaling, SpriteEffects.None, 0); } return false; } } + + public class UnstableDustPixelated : UnstableDust + { + public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), Enums.GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Vector2 squash = new Vector2(0.4f, 1); + float texScaling = 6; + + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.1f * texScaling, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.04f * texScaling, SpriteEffects.None, 0); + if (!dust.noLight) + { + Main.spriteBatch.Draw(GlowStar.Value, dust.position - Main.screenPosition, null, Color.Lerp(dust.color, Color.White, 0.3f) with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, GlowStar.Size() * 0.5f, squash * dust.scale * 0.025f * texScaling, SpriteEffects.None, 0); + } + } + } } diff --git a/Dusts/VoidDust.cs b/Dusts/VoidDust.cs index 793f7b826d..e66a8f3bf4 100644 --- a/Dusts/VoidDust.cs +++ b/Dusts/VoidDust.cs @@ -1,6 +1,9 @@ using System; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +11,19 @@ namespace CalamityMod.Dusts { public class VoidDust : ModDust { + public static Asset SolidCircle { get; private set; } + + public static Asset BloomCircle { get; private set; } + + public override void Load() + { + if (Main.dedServ) + return; + + SolidCircle = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle"); + BloomCircle = ModContent.Request("CalamityMod/Particles/BloomCircle"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -28,20 +44,41 @@ namespace CalamityMod.Dusts return true; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - Texture2D solidCenter = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; if (!dust.noLight) { - Texture2D bloom = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; // Glow Orb - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); } - Main.EntitySpriteDraw(solidCenter, dustCenter - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, solidCenter.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); return false; } } + + public class VoidDustPixelated : VoidDust + { + public override string Texture => "CalamityMod/Dusts/VoidDust"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + if (!dust.noLight) + { + // Glow Orb + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.1f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.85f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.04f, SpriteEffects.None, 0); + } + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + } + } } diff --git a/Dusts/VoidDustInverted.cs b/Dusts/VoidDustInverted.cs index d5df7d199f..4c30aec8d8 100644 --- a/Dusts/VoidDustInverted.cs +++ b/Dusts/VoidDustInverted.cs @@ -1,6 +1,9 @@ using System; +using CalamityMod.Enums; +using CalamityMod.Systems.Graphic.PixelationSystem; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; +using ReLogic.Content; using Terraria; using Terraria.ModLoader; @@ -8,6 +11,22 @@ namespace CalamityMod.Dusts { public class VoidDustInverted : ModDust { + public static Asset SolidCircle { get; private set; } + + public static Asset BloomCircle { get; private set; } + + public static Asset SmallBloomCircle { get; private set; } + + public override void Load() + { + if (Main.dedServ) + return; + + SolidCircle = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle"); + BloomCircle = ModContent.Request("CalamityMod/Particles/BloomCircle"); + SmallBloomCircle = ModContent.Request("CalamityMod/Particles/SmallBloom"); + } + public override void OnSpawn(Dust dust) { dust.scale *= Main.rand.NextFloat(0.8f, 1f); @@ -28,23 +47,39 @@ namespace CalamityMod.Dusts return true; } + public override bool PreDraw(Dust dust) { - Vector2 dustCenter = dust.position + new Vector2(0.25f, 0.25f); - - Texture2D solidCenter = ModContent.Request("CalamityMod/ExtraTextures/BasicCircle").Value; - Texture2D bloom2 = ModContent.Request("CalamityMod/Particles/BloomCircle").Value; - - Texture2D bloom = ModContent.Request("CalamityMod/Particles/SmallBloom").Value; - - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Black * 0.4f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.068f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SmallBloomCircle.Value, dust.position - Main.screenPosition, null, Color.Black * 0.4f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SmallBloomCircle.Size() * 0.5f, dust.scale * 0.068f, SpriteEffects.None, 0); if (dust.alpha < 1) - Main.EntitySpriteDraw(bloom, dustCenter - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom.Size() * 0.5f, dust.scale * 0.057f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SmallBloomCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SmallBloomCircle.Size() * 0.5f, dust.scale * 0.057f, SpriteEffects.None, 0); - Main.EntitySpriteDraw(bloom2, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, bloom2.Size() * 0.5f, dust.scale * 0.07f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.07f, SpriteEffects.None, 0); if (!dust.noLight) - Main.EntitySpriteDraw(solidCenter, dustCenter - Main.screenPosition, null, dust.color with { A = 0 } * 0.75f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, solidCenter.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.75f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); return false; } } + + public class VoidDustInvertedPixelated : VoidDustInverted + { + public override string Texture => "CalamityMod/Dusts/VoidDustInverted"; + + public override bool PreDraw(Dust dust) + { + PixelationManager.AddPixelatedDrawer((_) => DrawPixelated(dust), GeneralDrawLayer.AfterDusts); + return false; + } + + private static void DrawPixelated(Dust dust) + { + Main.spriteBatch.Draw(SmallBloomCircle.Value, dust.position - Main.screenPosition, null, Color.Black * 0.4f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SmallBloomCircle.Size() * 0.5f, dust.scale * 0.068f, SpriteEffects.None, 0); + if (dust.alpha < 1) + Main.spriteBatch.Draw(SmallBloomCircle.Value, dust.position - Main.screenPosition, null, Color.Black * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SmallBloomCircle.Size() * 0.5f, dust.scale * 0.057f, SpriteEffects.None, 0); + + Main.spriteBatch.Draw(BloomCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, BloomCircle.Size() * 0.5f, dust.scale * 0.07f, SpriteEffects.None, 0); + if (!dust.noLight) + Main.spriteBatch.Draw(SolidCircle.Value, dust.position - Main.screenPosition, null, dust.color with { A = 0 } * 0.75f * Utils.GetLerpValue(255, 0, dust.alpha), dust.rotation, SolidCircle.Size() * 0.5f, dust.scale * 0.075f, SpriteEffects.None, 0); + } + } } diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs index 873bf88ae8..bb495b64dc 100644 --- a/Particles/GeneralParticleHandler.cs +++ b/Particles/GeneralParticleHandler.cs @@ -57,15 +57,13 @@ namespace CalamityMod.Particles /// internal static Dictionary particleTexturesByIDs; - /// - /// All types defined across all mods, identified by the type of the particle the drawers target. - /// - internal static Dictionary particleAutoDrawingOverrides; + private static Dictionary particleAutoDrawingOverrides; private static List activeParticles; private static List particlesToKill; private static Dictionary> particlesToSpawnNextFrame; private static Dictionary> particlesToSpawnNextFrame_Pixelated; + private static Dictionary> particlesToDraw; private static Dictionary> particlesToDraw_Pixelated; #endregion @@ -166,6 +164,7 @@ namespace CalamityMod.Particles /// /// Spawns the particle instance provided into the world. If the particle limit is reached but the particle is marked as important, it will try to replace a non important particle. /// + /// Set to true to force the particle being spawned to be drawn pixelated. /// Only set this to a non-null value if you'd like to manually override the draw layer of the particle instance you are spawning. public static void SpawnParticle(Particle particle, bool pixelate = false, GeneralDrawLayer? manualDrawLayerOverride = null) { diff --git a/Systems/Graphic/PixelationSystem/PixelationManager.cs b/Systems/Graphic/PixelationSystem/PixelationManager.cs index c3d80ecc30..00628ffda8 100644 --- a/Systems/Graphic/PixelationSystem/PixelationManager.cs +++ b/Systems/Graphic/PixelationSystem/PixelationManager.cs @@ -213,7 +213,7 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem { blendStateTargetPair.Value.SwapTo(); - Main.spriteBatch.Begin(default, blendStateTargetPair.Key, SamplerState.LinearClamp, default, default, null, pixelationMatrix); + Main.spriteBatch.Begin(default, blendStateTargetPair.Key, Main.DefaultSamplerState, DepthStencilState.None, Main.Rasterizer, null, pixelationMatrix); // Select only drawers who match this target's BlendState. var drawersByBlendState = drawerCollection.Where(d => d.DefaultBlendState == blendStateTargetPair.Key).ToList(); @@ -236,7 +236,7 @@ namespace CalamityMod.Systems.Graphic.PixelationSystem foreach (var keyValuePair in targetCollection) { Main.spriteBatch.TryEnd(); - Main.spriteBatch.TryBegin(SpriteSortMode.Deferred, keyValuePair.Key, Main.DefaultSamplerState, default, default, null, Main.GameViewMatrix.TransformationMatrix); + Main.spriteBatch.TryBegin(default, keyValuePair.Key, SamplerState.PointClamp, DepthStencilState.None, Main.Rasterizer, null, Main.GameViewMatrix.TransformationMatrix); float targetScale = 1f / PixelationResolution; Main.spriteBatch.Draw(keyValuePair.Value, Vector2.Zero, null, Color.White, 0f, Vector2.Zero, targetScale, SpriteEffects.None, 0f);