;jCiC7TI|E
zAX2F%4vKIw)?OaDR-sH{zv**qKV8FKLKK}a-q5R5NjPZ2kL?fv%c7@#WV7r?ka#Jl
zdh;$JjOqdLWvT(^-d+|yZUFqFIWBJJZ>to7ti6OtSpUHz*Z7Lk2oM>SW2=8v?#EV#
zx&`uKyI6LLf^MPOo0C5@0Gb^{Otdy@CjS?A?!^OI8yk1*#WG1G)c-3Svkhc5Og-md
Sl%9}SmaB%>4660r68;B;tCYV0
literal 0
HcmV?d00001
diff --git a/Particles/GenericSparkle.cs b/Particles/GenericSparkle.cs
index 7e8b44a156..0b5ce64c20 100644
--- a/Particles/GenericSparkle.cs
+++ b/Particles/GenericSparkle.cs
@@ -1,27 +1,55 @@
using Microsoft.Xna.Framework;
+using Microsoft.Xna.Framework.Graphics;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using Terraria;
+using Terraria.ModLoader;
namespace CalamityMod.Particles
{
public class GenericSparkle : Particle
{
public override string Texture => "CalamityMod/Particles/Sparkle";
+ public override bool UseAdditiveBlend => true;
+ public override bool UseCustomDraw => true;
+ public override bool SetLifetime => true;
- public GenericSparkle(Vector2 position, Vector2 velocity, Color color, float scale, int lifeTime, float rotationSpeed = 1f)
+ private float Spin;
+ private float opacity;
+ private Color Bloom;
+ private Color LightColor => Bloom * opacity;
+ private float BloomScale;
+
+ public GenericSparkle(Vector2 position, Vector2 velocity, Color color, Color bloom, float scale, int lifeTime, float rotationSpeed = 1f, float bloomScale = 1f)
{
Position = position;
Velocity = velocity;
Color = color;
+ Bloom = bloom;
Scale = scale;
Lifetime = lifeTime;
Rotation = Main.rand.NextFloat(MathHelper.TwoPi);
+ Spin = rotationSpeed;
+ BloomScale = bloomScale;
}
+ public override void Update()
+ {
+ opacity = (float)Math.Sin(LifetimeCompletion * MathHelper.Pi);
+ Lighting.AddLight(Position, LightColor.R / 255f, LightColor.G / 255f, LightColor.B / 255f);
+ Velocity *= 0.95f;
+ Rotation += Spin * ((Velocity.X > 0) ? 1f : -1f);
+ }
+ public override void CustomDraw(SpriteBatch spriteBatch)
+ {
+ Texture2D starTexture = GeneralParticleHandler.GetTexture(Type);
+ Texture2D bloomTexture = ModContent.GetTexture("CalamityMod/Particles/BloomCircle");
+ //Ajust the bloom's texture to be the same size as the star's
+ float properBloomSize = starTexture.Height / bloomTexture.Height;
+
+ spriteBatch.Draw(bloomTexture, Position - Main.screenPosition, null, Bloom * opacity * 0.5f, 0, bloomTexture.Size()/2f, Scale * BloomScale * properBloomSize, SpriteEffects.None, 0);
+ spriteBatch.Draw(starTexture, Position - Main.screenPosition, null, Color * opacity * 0.5f, Rotation + MathHelper.PiOver4, starTexture.Size() / 2f, Scale * 0.75f, SpriteEffects.None, 0);
+ spriteBatch.Draw(starTexture, Position - Main.screenPosition, null, Color * opacity, Rotation, starTexture.Size() / 2f, Scale, SpriteEffects.None, 0);
+ }
}
}
From ae92e313beda3205ec0499ad76c41536e70106ed Mon Sep 17 00:00:00 2001
From: IbanPlay <56191483+IbanPlay@users.noreply.github.com>
Date: Thu, 6 Jan 2022 23:08:55 +0100
Subject: [PATCH 8/9] Particle cap config
---
CalamityConfig.cs | 8 ++++++++
Particles/GeneralParticleHandler.cs | 2 +-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/CalamityConfig.cs b/CalamityConfig.cs
index 4a38eca484..e8b9591f41 100644
--- a/CalamityConfig.cs
+++ b/CalamityConfig.cs
@@ -30,6 +30,14 @@ namespace CalamityMod
[Tooltip("Enables rendering afterimages for Calamity NPCs, projectiles, etc.\nDisable to improve performance.")]
public bool Afterimages { get; set; }
+ [Label("Maximum particles")]
+ [BackgroundColor(192, 54, 64, 192)]
+ [SliderColor(224, 165, 56, 128)]
+ [Range(0, 1000)]
+ [DefaultValue(500)]
+ [Tooltip("Sets the maximum of particle effects that can exist at once.\nParticles are separate from dust and gores.\nTurn down to improve performance.")]
+ public int ParticleLimit { get; set; }
+
[Label("Disable Screenshakes")]
[BackgroundColor(192, 54, 64, 192)]
[DefaultValue(false)]
diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs
index 52788d3e79..a0beecd252 100644
--- a/Particles/GeneralParticleHandler.cs
+++ b/Particles/GeneralParticleHandler.cs
@@ -17,7 +17,7 @@ namespace CalamityMod.Particles
/// This is the maximum of particles allowed. Particles marked as important may replace nonimportant particles when the cap is reached
///
// May be a good idea to make this into a config option
- private static readonly int particleCap = 500;
+ private static readonly int particleCap = CalamityConfig.Instance.ParticleLimit;
private static Particle[] particles;
private static int nextVacantIndex;
From 8afe663d7e6236ffc89dbef1d292e3db07e903a9 Mon Sep 17 00:00:00 2001
From: IbanPlay <56191483+IbanPlay@users.noreply.github.com>
Date: Fri, 7 Jan 2022 01:13:52 +0100
Subject: [PATCH 9/9] Configurable particle cap better now
---
Particles/GeneralParticleHandler.cs | 46 +++++++----------------------
Particles/GenericSparkle.cs | 2 +-
Particles/Particle.cs | 9 ++++--
3 files changed, 18 insertions(+), 39 deletions(-)
diff --git a/Particles/GeneralParticleHandler.cs b/Particles/GeneralParticleHandler.cs
index a0beecd252..2be3028795 100644
--- a/Particles/GeneralParticleHandler.cs
+++ b/Particles/GeneralParticleHandler.cs
@@ -13,15 +13,8 @@ namespace CalamityMod.Particles
{
public static class GeneralParticleHandler
{
- ///