diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index e0421dd2f8..69988d269c 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -3868,7 +3868,7 @@ namespace CalamityMod.CalPlayer else { // Reset buff persistence if Amalgam is removed. - if (Main.persistentBuff[buffID] && !CalamityLists.persistentBuffList.Contains(buffID)) + if (Main.persistentBuff[buffID] && !PersistentBuffList.IsPersistentBuff(buffID)) Main.persistentBuff[buffID] = false; } } diff --git a/CalamityLists.cs b/CalamityLists.cs index 9a9c5025e6..3be3e1a07b 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -66,7 +66,6 @@ namespace CalamityMod { public sealed class CalamityLists : ModSystem { - public static List persistentBuffList; public static List MagicGunIDs; public static List BlacklistedWeaponsWithToolPower; @@ -127,21 +126,6 @@ namespace CalamityMod public override void OnModLoad() { - persistentBuffList = new List() - { - BuffType(), - BuffType(), - BuffType(), - BuffID.WeaponImbueVenom, - BuffID.WeaponImbueCursedFlames, - BuffID.WeaponImbueFire, - BuffID.WeaponImbueGold, - BuffID.WeaponImbueIchor, - BuffID.WeaponImbueNanites, - BuffID.WeaponImbueConfetti, - BuffID.WeaponImbuePoison - }; - MagicGunIDs = new List() { ItemType(), @@ -1182,7 +1166,6 @@ namespace CalamityMod public override void Unload() { - persistentBuffList = null; MagicGunIDs = null; BlacklistedWeaponsWithToolPower = null; diff --git a/ModSupport/ModCalls.cs b/ModSupport/ModCalls.cs index 497faf2f37..934efc430c 100644 --- a/ModSupport/ModCalls.cs +++ b/ModSupport/ModCalls.cs @@ -929,21 +929,21 @@ namespace CalamityMod } public static bool SetPersistentBuffList(int type, bool isPersistent) { - if (isPersistent && !CalamityLists.persistentBuffList.Contains(type)) + if (isPersistent && !PersistentBuffList.IsPersistentBuff(type)) { - CalamityLists.persistentBuffList.Add(type); + PersistentBuffList.List.Add(type); return true; } else if (!isPersistent) { - return CalamityLists.persistentBuffList.Remove(type); + return PersistentBuffList.List.Remove(type); } return false; } public static bool IsOnAmalgamBuffList(int type) => AmalgamBuffList.IsBuffBoostedByAmalgan(type); - public static bool IsOnPersistentBuffList(int type) => CalamityLists.persistentBuffList.Contains(type); + public static bool IsOnPersistentBuffList(int type) => PersistentBuffList.IsPersistentBuff(type); #endregion #region Venerated Locket Bans diff --git a/Systems/Collections/PersistentBuffList.cs b/Systems/Collections/PersistentBuffList.cs new file mode 100644 index 0000000000..58d25c743f --- /dev/null +++ b/Systems/Collections/PersistentBuffList.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CalamityMod.Buffs.Potions; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + public sealed class PersistentBuffList : ModSystem + { + public static IList List { get; private set; } + + public override void OnModLoad() + { + List = + [ + BuffType(), + BuffType(), + BuffType(), + BuffID.WeaponImbueVenom, + BuffID.WeaponImbueCursedFlames, + BuffID.WeaponImbueFire, + BuffID.WeaponImbueGold, + BuffID.WeaponImbueIchor, + BuffID.WeaponImbueNanites, + BuffID.WeaponImbueConfetti, + BuffID.WeaponImbuePoison + ]; + } + + public override void Unload() => List = null; + + /// + /// A shorthand method to check if this buffType is a PersistentBuff. + /// + public static bool IsPersistentBuff(int buffType) => List.Contains(buffType); + } +}