diff --git a/CalPlayer/CalamityPlayerLifeRegen.cs b/CalPlayer/CalamityPlayerLifeRegen.cs index 92cd348b65..46400873cb 100644 --- a/CalPlayer/CalamityPlayerLifeRegen.cs +++ b/CalPlayer/CalamityPlayerLifeRegen.cs @@ -16,6 +16,7 @@ using CalamityMod.NPCs; using CalamityMod.Projectiles.Ranged; using CalamityMod.Projectiles.Typeless; using CalamityMod.Systems; +using CalamityMod.Systems.Collections; using CalamityMod.World; using Microsoft.Xna.Framework; using Terraria; @@ -390,9 +391,9 @@ namespace CalamityMod.CalPlayer continue; bool shouldHalveDuration = CalamityLists.sicknessDebuffList.Contains(buffID); if (livingDewHalveDebuffs) - shouldHalveDuration |= CalamityLists.fireDebuffList.Contains(buffID); + shouldHalveDuration |= FireDebuffsList.IsFireDebuff(buffID); if (purity) - shouldHalveDuration |= CalamityLists.debuffList.Contains(buffID); + shouldHalveDuration |= DebuffsList.IsDebuff(buffID); if (shouldHalveDuration) --Player.buffTime[l]; @@ -456,7 +457,7 @@ namespace CalamityMod.CalPlayer if (purity) { int intendedPurityDefense = 0; - int currentDebuffs = Player.buffType.Count(CalamityLists.debuffList.Contains); + int currentDebuffs = Player.buffType.Count(DebuffsList.List.Contains); if (currentDebuffs > 0) { // Healing rate is normally 5 HP/s (+1 every 12 frames) @@ -509,7 +510,7 @@ namespace CalamityMod.CalPlayer // If the player has any debuffs, give the extra life regen and defense // More defense is given for each additional debuff int intendedJewelDefense = 0; - int currentDebuffs = Player.buffType.Count(CalamityLists.debuffList.Contains); + int currentDebuffs = Player.buffType.Count(DebuffsList.List.Contains); if (currentDebuffs > 0) { Player.lifeRegen += 4; @@ -536,7 +537,7 @@ namespace CalamityMod.CalPlayer Player.lifeRegen += 2; // If any debuff is detected, provide even more life regen and massively accelerate it - if (Player.buffType.Any(CalamityLists.debuffList.Contains)) + if (Player.buffType.Any(DebuffsList.List.Contains)) { Player.lifeRegen += 3; if (Player.lifeRegenTime < 1800) diff --git a/CalamityLists.cs b/CalamityLists.cs index 6c272647da..956b98d2c1 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -153,22 +153,7 @@ namespace CalamityMod public override void OnModLoad() { - fireDebuffList = new List() - { - BuffID.OnFire, - BuffID.OnFire3, // Hellfire - BuffID.Burning, // Touching meteorite ore or hellstone without obsidian skull - BuffID.CursedInferno, - BuffID.ShadowFlame, // Vanilla Shadowflame, can normally never be applied to players - BuffType(), // Calamity Shadowflame copy for players - BuffType(), // Crags lava - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), // Aflame enchant self damage - BuffType(), - }; + fireDebuffList sicknessDebuffList = new List() { diff --git a/Systems/Collections/FireDebuffsList.cs b/Systems/Collections/FireDebuffsList.cs new file mode 100644 index 0000000000..dabf894cb4 --- /dev/null +++ b/Systems/Collections/FireDebuffsList.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using CalamityMod.Buffs.DamageOverTime; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + /// + /// A that contains a that has all the IDs of all Fire-type debuffs. + /// + public sealed class FireDebuffsList : ModSystem + { + public static IList List { get; private set; } + + public override void OnModLoad() + { + List = + [ + BuffID.OnFire, + BuffID.OnFire3, // Hellfire + BuffID.Burning, // Touching meteorite ore or hellstone without obsidian skull + BuffID.CursedInferno, + BuffID.ShadowFlame, // Vanilla Shadowflame, can normally never be applied to players + BuffType(), // Calamity Shadowflame copy for players + BuffType(), // Crags lava + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), // Aflame enchant self damage + BuffType(), + ]; + } + + public override void Unload() => List = null; + + /// + /// A shorthand method to check if a buff ID is a fire debuff. + /// + public static bool IsFireDebuff(int buffID) => List.Contains(buffID); + } +}