From 557d86144199144ec0c533e5797ea877dd01f255 Mon Sep 17 00:00:00 2001 From: Memes <114233643+Mr-Memes@users.noreply.github.com> Date: Wed, 16 Oct 2024 00:13:40 +0200 Subject: [PATCH] DebuffsList. --- CalPlayer/CalamityPlayerMiscEffects.cs | 7 +- CalamityLists.cs | 73 ---------------- NPCs/SupremeCalamitas/SupremeCalamitas.cs | 3 +- Projectiles/Healing/AbsorberAura.cs | 5 +- Projectiles/Healing/BlueJellyAura.cs | 5 +- Projectiles/Healing/GreenJellyAura.cs | 5 +- Systems/Collections/DebuffsList.cs | 100 ++++++++++++++++++++++ 7 files changed, 115 insertions(+), 83 deletions(-) create mode 100644 Systems/Collections/DebuffsList.cs diff --git a/CalPlayer/CalamityPlayerMiscEffects.cs b/CalPlayer/CalamityPlayerMiscEffects.cs index 86dd0baf5a..5d8c41681b 100644 --- a/CalPlayer/CalamityPlayerMiscEffects.cs +++ b/CalPlayer/CalamityPlayerMiscEffects.cs @@ -82,6 +82,7 @@ using Terraria.ID; using Terraria.ModLoader; using ProvidenceBoss = CalamityMod.NPCs.Providence.Providence; using CalamityMod.Projectiles.Pets; +using CalamityMod.Systems.Collections; namespace CalamityMod.CalPlayer { @@ -1932,12 +1933,12 @@ namespace CalamityMod.CalPlayer for (int l = 0; l < Player.MaxBuffs; l++) { - int hasBuff = Player.buffType[l]; - if (Player.buffTime[l] <= 2 && hasBuff == ModContent.BuffType()) + int buffID = Player.buffType[l]; + if (Player.buffTime[l] <= 2 && buffID == ModContent.BuffType()) if (Player.whoAmI == Main.myPlayer) Player.AddCooldown(Cooldowns.TarragonImmunity.ID, CalamityUtils.SecondsToFrames(25)); - bool shouldAffect = CalamityLists.debuffList.Contains(hasBuff); + bool shouldAffect = DebuffsList.IsDebuff(buffID); if (shouldAffect) Player.GetDamage() += 0.1f; } diff --git a/CalamityLists.cs b/CalamityLists.cs index fd49eb5dc6..6c272647da 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -77,7 +77,6 @@ namespace CalamityMod { public sealed class CalamityLists : ModSystem { - public static List debuffList; public static List fireDebuffList; public static List sicknessDebuffList; public static List alcoholList; @@ -154,77 +153,6 @@ namespace CalamityMod public override void OnModLoad() { - debuffList = new List() - { - BuffID.Poisoned, - BuffID.Darkness, - BuffID.Cursed, - BuffID.OnFire, - BuffID.Bleeding, - BuffID.Confused, - BuffID.Slow, - BuffID.Weak, - BuffID.Silenced, - BuffID.BrokenArmor, - BuffID.CursedInferno, - BuffID.Frostburn, - BuffID.Chilled, - BuffID.Frozen, - BuffID.Burning, - BuffID.Suffocation, - BuffID.Ichor, - BuffID.Venom, - BuffID.Blackout, - BuffID.Electrified, - BuffID.Rabies, - BuffID.Webbed, - BuffID.Stoned, - BuffID.Dazed, - BuffID.VortexDebuff, - BuffID.WitheredArmor, - BuffID.WitheredWeapon, - BuffID.OgreSpit, - BuffID.BetsysCurse, - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType(), - // BuffType(), - BuffType(), - BuffType(), - BuffType(), - BuffType() - }; - fireDebuffList = new List() { BuffID.OnFire, @@ -1659,7 +1587,6 @@ namespace CalamityMod public override void Unload() { - debuffList = null; fireDebuffList = null; sicknessDebuffList = null; alcoholList = null; diff --git a/NPCs/SupremeCalamitas/SupremeCalamitas.cs b/NPCs/SupremeCalamitas/SupremeCalamitas.cs index 70b5837865..8043e814eb 100644 --- a/NPCs/SupremeCalamitas/SupremeCalamitas.cs +++ b/NPCs/SupremeCalamitas/SupremeCalamitas.cs @@ -45,6 +45,7 @@ using CalamityMod.Projectiles.Ranged; using Steamworks; using CalamityMod.Particles; using Terraria.Utilities.Terraria.Utilities; +using CalamityMod.Systems.Collections; namespace CalamityMod.NPCs.SupremeCalamitas { @@ -1612,7 +1613,7 @@ namespace CalamityMod.NPCs.SupremeCalamitas { int buffID = NPC.buffType[l]; - bool shouldHalveDuration = CalamityLists.debuffList.Contains(buffID); + bool shouldHalveDuration = DebuffsList.IsDebuff(buffID); if (shouldHalveDuration && NPC.buffTime[l] > 4) NPC.buffTime[l] = 4; diff --git a/Projectiles/Healing/AbsorberAura.cs b/Projectiles/Healing/AbsorberAura.cs index a4f44ec2f3..81429fed0a 100644 --- a/Projectiles/Healing/AbsorberAura.cs +++ b/Projectiles/Healing/AbsorberAura.cs @@ -6,6 +6,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Accessories; using CalamityMod.Particles; +using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -58,8 +59,8 @@ namespace CalamityMod.Projectiles.Healing CleansingEffect = 1; for (int l = 0; l < Player.MaxBuffs; l++) { - int hasBuff = player.buffType[l]; - if (player.buffTime[l] > 2 && CalamityLists.debuffList.Contains(hasBuff)) + int buffID = player.buffType[l]; + if (player.buffTime[l] > 2 && DebuffsList.IsDebuff(buffID)) { player.buffTime[l] *= 0; } diff --git a/Projectiles/Healing/BlueJellyAura.cs b/Projectiles/Healing/BlueJellyAura.cs index 1725c2fc9a..a7e947e665 100644 --- a/Projectiles/Healing/BlueJellyAura.cs +++ b/Projectiles/Healing/BlueJellyAura.cs @@ -6,6 +6,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Accessories; using CalamityMod.Particles; +using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -56,8 +57,8 @@ namespace CalamityMod.Projectiles.Healing CleansingEffect = 1; for (int l = 0; l < Player.MaxBuffs; l++) { - int hasBuff = player.buffType[l]; - if (player.buffTime[l] > 2 && CalamityLists.debuffList.Contains(hasBuff)) + int buffID = player.buffType[l]; + if (player.buffTime[l] > 2 && DebuffsList.IsDebuff(buffID)) { player.buffTime[l] *= 0; } diff --git a/Projectiles/Healing/GreenJellyAura.cs b/Projectiles/Healing/GreenJellyAura.cs index 5ae975ea63..c8882093f0 100644 --- a/Projectiles/Healing/GreenJellyAura.cs +++ b/Projectiles/Healing/GreenJellyAura.cs @@ -6,6 +6,7 @@ using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Items.Accessories; using CalamityMod.Particles; +using CalamityMod.Systems.Collections; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Terraria; @@ -58,8 +59,8 @@ namespace CalamityMod.Projectiles.Healing CleansingEffect = 1; for (int l = 0; l < Player.MaxBuffs; l++) { - int hasBuff = player.buffType[l]; - if (player.buffTime[l] > 2 && CalamityLists.debuffList.Contains(hasBuff)) + int buffID = player.buffType[l]; + if (player.buffTime[l] > 2 && DebuffsList.IsDebuff(buffID)) { player.buffTime[l] *= 0; } diff --git a/Systems/Collections/DebuffsList.cs b/Systems/Collections/DebuffsList.cs new file mode 100644 index 0000000000..6dc4cd1f66 --- /dev/null +++ b/Systems/Collections/DebuffsList.cs @@ -0,0 +1,100 @@ +using System.Collections.Generic; +using CalamityMod.Buffs; +using CalamityMod.Buffs.Cooldowns; +using CalamityMod.Buffs.DamageOverTime; +using CalamityMod.Buffs.StatDebuffs; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + /// + /// A that contains a that has all Debuff IDs. + /// + public sealed class DebuffsList : ModSystem + { + public static IList List { get; private set; } + + public override void OnModLoad() + { + List = + [ + BuffID.Poisoned, + BuffID.Darkness, + BuffID.Cursed, + BuffID.OnFire, + BuffID.Bleeding, + BuffID.Confused, + BuffID.Slow, + BuffID.Weak, + BuffID.Silenced, + BuffID.BrokenArmor, + BuffID.CursedInferno, + BuffID.Frostburn, + BuffID.Chilled, + BuffID.Frozen, + BuffID.Burning, + BuffID.Suffocation, + BuffID.Ichor, + BuffID.Venom, + BuffID.Blackout, + BuffID.Electrified, + BuffID.Rabies, + BuffID.Webbed, + BuffID.Stoned, + BuffID.Dazed, + BuffID.VortexDebuff, + BuffID.WitheredArmor, + BuffID.WitheredWeapon, + BuffID.OgreSpit, + BuffID.BetsysCurse, + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType(), + // BuffType(), + BuffType(), + BuffType(), + BuffType(), + BuffType() + ]; + } + + public override void Unload() => List = null; + + /// + /// A shorthand method to check if a buff ID is a debuff. + /// + public static bool IsDebuff(int buffID) => List.Contains(buffID); + } +}