Obscure load problem fix

This commit is contained in:
Dominic committed 2022-01-24 00:54:43 -06:00
1 parent 384dc2f984
commit 6e00a073ab
2 files changed
+7 -1

No files matched your search

+2 -1
View File
@@ -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);
}
+5
View File
@@ -19,6 +19,7 @@ namespace CalamityMod.Particles
public static class FusableParticleManager
{
internal static List<FusableParticleRenderCollection> ParticleSets = new List<FusableParticleRenderCollection>();
internal static bool HasBeenFormallyDefined = false;
/// <summary>
/// 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<FusableParticleRenderCollection>();
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;
}