From 6e00a073ab6ec420c86fa5645a259125a70dbb82 Mon Sep 17 00:00:00 2001 From: Dominic Date: Mon, 24 Jan 2022 00:54:43 -0600 Subject: [PATCH] Obscure load problem fix --- ILEditing/MechanicILChanges.cs | 3 ++- Particles/FusableParticleManager.cs | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ILEditing/MechanicILChanges.cs b/ILEditing/MechanicILChanges.cs index c4532df202..c6958dee34 100644 --- a/ILEditing/MechanicILChanges.cs +++ b/ILEditing/MechanicILChanges.cs @@ -509,7 +509,8 @@ namespace CalamityMod.ILEditing #region Custom Lava Visuals private static void ResetRenderTargetSizes(On.Terraria.Main.orig_SetDisplayMode orig, int width, int height, bool fullscreen) { - FusableParticleManager.LoadParticleRenderSets(true, width, height); + if (FusableParticleManager.HasBeenFormallyDefined) + FusableParticleManager.LoadParticleRenderSets(true, width, height); orig(width, height, fullscreen); } diff --git a/Particles/FusableParticleManager.cs b/Particles/FusableParticleManager.cs index a38ba79fcc..5313e4f48a 100644 --- a/Particles/FusableParticleManager.cs +++ b/Particles/FusableParticleManager.cs @@ -19,6 +19,7 @@ namespace CalamityMod.Particles public static class FusableParticleManager { internal static List ParticleSets = new List(); + internal static bool HasBeenFormallyDefined = false; /// /// Loads all render sets. @@ -44,7 +45,10 @@ namespace CalamityMod.Particles // Redefine the particle set list in case the mod was reloaded and this field was nullified during that. // This does not happen during reloads, as that would delete particles outside of load-time. if (!reload) + { ParticleSets = new List(); + HasBeenFormallyDefined = true; + } // Look through every type in the mod, and check if it's derived from BaseFusableParticleSet. // If it is, create a default instance of said particle, save it, and create a RenderTarget2D for each individual texture/shader. @@ -84,6 +88,7 @@ namespace CalamityMod.Particles foreach (RenderTarget2D target in particleRenderSet.BackgroundTargets) target?.Dispose(); } + HasBeenFormallyDefined = false; ParticleSets = null; }