From a2fc330e47f4e1a2a5e091bb87ae1fccf1c1ba29 Mon Sep 17 00:00:00 2001 From: Memes <114233643+Mr-Memes@users.noreply.github.com> Date: Tue, 15 Oct 2024 23:57:42 +0200 Subject: [PATCH] FriendlyBeesList. --- CalPlayer/CalamityPlayerOnHit.cs | 2 +- CalamityLists.cs | 13 --------- Systems/Collections/FriendlyBeesList.cs | 39 +++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 Systems/Collections/FriendlyBeesList.cs diff --git a/CalPlayer/CalamityPlayerOnHit.cs b/CalPlayer/CalamityPlayerOnHit.cs index 8e2cdefd72..3323172001 100644 --- a/CalPlayer/CalamityPlayerOnHit.cs +++ b/CalPlayer/CalamityPlayerOnHit.cs @@ -281,7 +281,7 @@ namespace CalamityMod.CalPlayer if (!proj.npcProj && !proj.trap && proj.friendly) { - if ((plaguebringerCarapace || uberBees) && CalamityLists.friendlyBeeList.Contains(proj.type)) + if ((plaguebringerCarapace || uberBees) && FriendlyBeesList.IsFriendlyBee(proj)) target.AddBuff(BuffType(), 300); // All projectiles fired from Soma Prime are marked using CalamityGlobalProjectile diff --git a/CalamityLists.cs b/CalamityLists.cs index 69f83451f9..fd49eb5dc6 100644 --- a/CalamityLists.cs +++ b/CalamityLists.cs @@ -77,7 +77,6 @@ namespace CalamityMod { public sealed class CalamityLists : ModSystem { - public static List friendlyBeeList; public static List debuffList; public static List fireDebuffList; public static List sicknessDebuffList; @@ -155,17 +154,6 @@ namespace CalamityMod public override void OnModLoad() { - friendlyBeeList = new List() - { - ProjectileID.GiantBee, - ProjectileID.Bee, - ProjectileID.Wasp, - ProjectileType(), - ProjectileType(), - ProjectileType(), - ProjectileType() - }; - debuffList = new List() { BuffID.Poisoned, @@ -1671,7 +1659,6 @@ namespace CalamityMod public override void Unload() { - friendlyBeeList = null; debuffList = null; fireDebuffList = null; sicknessDebuffList = null; diff --git a/Systems/Collections/FriendlyBeesList.cs b/Systems/Collections/FriendlyBeesList.cs new file mode 100644 index 0000000000..370b8a76f3 --- /dev/null +++ b/Systems/Collections/FriendlyBeesList.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using CalamityMod.Projectiles.Rogue; +using CalamityMod.Projectiles.Summon; +using Terraria; +using Terraria.ID; +using Terraria.ModLoader; +using static Terraria.ModLoader.ModContent; + +namespace CalamityMod.Systems.Collections +{ + /// + /// A that contains a that has all the Projectile IDs of all friendly bees. + /// + public sealed class FriendlyBeesList : ModSystem + { + public static IList List { get; private set; } + + public override void OnModLoad() + { + List = + [ + ProjectileID.GiantBee, + ProjectileID.Bee, + ProjectileID.Wasp, + ProjectileType(), + ProjectileType(), + ProjectileType(), + ProjectileType() + ]; + } + + public override void Unload() => List = null; + + /// + /// A shorthand method to check if a projectile is a friendly bee. + /// + public static bool IsFriendlyBee(Projectile proj) => List.Contains(proj.type); + } +}