From d2290112643e8c71a8cc28582da5e7c0e1f0d1e6 Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Wed, 1 Jun 2022 16:03:34 -0500 Subject: [PATCH 1/2] Critter Companionship Guide fixes for Cal critters --- NPCs/AcidRain/BabyFlakCrab.cs | 7 ++++--- NPCs/AcidRain/BloodwormNormal.cs | 7 ++++--- NPCs/Astral/EnchantedNightcrawler.cs | 3 ++- NPCs/Astral/Twinkler.cs | 2 +- NPCs/DraedonLabThings/RepairUnitCritter.cs | 2 +- NPCs/NormalNPCs/Piggy.cs | 1 + NPCs/SunkenSea/BabyGhostBell.cs | 7 ++++--- NPCs/SunkenSea/SeaMinnow.cs | 7 ++++--- 8 files changed, 21 insertions(+), 15 deletions(-) diff --git a/NPCs/AcidRain/BabyFlakCrab.cs b/NPCs/AcidRain/BabyFlakCrab.cs index fa6125211d..bf321768b1 100644 --- a/NPCs/AcidRain/BabyFlakCrab.cs +++ b/NPCs/AcidRain/BabyFlakCrab.cs @@ -18,6 +18,7 @@ namespace CalamityMod.NPCs.AcidRain DisplayName.SetDefault("Baby Flak Crab"); Main.npcFrameCount[NPC.type] = 6; Main.npcCatchable[NPC.type] = true; + NPCID.Sets.CountsAsCritter[NPC.type] = true; } public override void SetDefaults() @@ -44,10 +45,10 @@ namespace CalamityMod.NPCs.AcidRain public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SulphurousSea, + //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SulphurousSea, - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Curiously, these seem to be intelligent enough to imprint a sort of parent figure if captured at a young enough age. They will stick with you forever!") + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("Curiously, these seem to be intelligent enough to imprint a sort of parent figure if captured at a young enough age. They will stick with you forever!") }); } diff --git a/NPCs/AcidRain/BloodwormNormal.cs b/NPCs/AcidRain/BloodwormNormal.cs index 6054ea3c4f..00917173f3 100644 --- a/NPCs/AcidRain/BloodwormNormal.cs +++ b/NPCs/AcidRain/BloodwormNormal.cs @@ -17,6 +17,7 @@ namespace CalamityMod.NPCs.AcidRain DisplayName.SetDefault("Bloodworm"); Main.npcFrameCount[NPC.type] = 7; Main.npcCatchable[NPC.type] = true; + NPCID.Sets.CountsAsCritter[NPC.type] = true; } public override void SetDefaults() @@ -81,10 +82,10 @@ namespace CalamityMod.NPCs.AcidRain public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SulphurousSea, + //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SulphurousSea, - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("A ripe-looking worm large enough to curl around your arm. A fish would have to be either mad enough or wise enough, to go after one of these.") + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("A ripe-looking worm large enough to curl around your arm. A fish would have to be either mad enough or wise enough, to go after one of these.") }); } diff --git a/NPCs/Astral/EnchantedNightcrawler.cs b/NPCs/Astral/EnchantedNightcrawler.cs index f7c791c166..c932f353a4 100644 --- a/NPCs/Astral/EnchantedNightcrawler.cs +++ b/NPCs/Astral/EnchantedNightcrawler.cs @@ -14,7 +14,8 @@ namespace CalamityMod.NPCs.Astral Main.npcCatchable[NPC.type] = true; NPCID.Sets.NPCBestiaryDrawModifiers bestiaryData = new NPCID.Sets.NPCBestiaryDrawModifiers(0){ Hide = true }; NPCID.Sets.NPCBestiaryDrawOffset.Add(Type, bestiaryData); - } + NPCID.Sets.CountsAsCritter[NPC.type] = true; + } public override void SetDefaults() { diff --git a/NPCs/Astral/Twinkler.cs b/NPCs/Astral/Twinkler.cs index 3c28d8479d..4b8634087b 100644 --- a/NPCs/Astral/Twinkler.cs +++ b/NPCs/Astral/Twinkler.cs @@ -15,6 +15,7 @@ namespace CalamityMod.NPCs.Astral DisplayName.SetDefault("Twinkler"); Main.npcFrameCount[NPC.type] = 8; Main.npcCatchable[NPC.type] = true; + NPCID.Sets.CountsAsCritter[NPC.type] = true; } public override void SetDefaults() @@ -25,7 +26,6 @@ namespace CalamityMod.NPCs.Astral AIType = NPCID.LightningBug; AnimationType = NPCID.LightningBug; NPC.catchItem = (short)ModContent.ItemType(); - NPC.friendly = true; // prevents critter from getting slagged //Banner = npc.type; //BannerItem = ModContent.ItemType(); } diff --git a/NPCs/DraedonLabThings/RepairUnitCritter.cs b/NPCs/DraedonLabThings/RepairUnitCritter.cs index 779ef195af..61b85d59a2 100644 --- a/NPCs/DraedonLabThings/RepairUnitCritter.cs +++ b/NPCs/DraedonLabThings/RepairUnitCritter.cs @@ -50,6 +50,7 @@ namespace CalamityMod.NPCs.DraedonLabThings { DisplayName.SetDefault("Repair Unit"); Main.npcFrameCount[NPC.type] = 17; + NPCID.Sets.CountsAsCritter[NPC.type] = true; } public override void SetDefaults() @@ -63,7 +64,6 @@ namespace CalamityMod.NPCs.DraedonLabThings NPC.knockBackResist = 0f; NPC.noGravity = true; NPC.noTileCollide = false; - NPC.friendly = true; NPC.HitSound = SoundID.NPCHit4; NPC.DeathSound = SoundID.NPCDeath44; } diff --git a/NPCs/NormalNPCs/Piggy.cs b/NPCs/NormalNPCs/Piggy.cs index 8b776e413f..23c21bfd0a 100644 --- a/NPCs/NormalNPCs/Piggy.cs +++ b/NPCs/NormalNPCs/Piggy.cs @@ -14,6 +14,7 @@ namespace CalamityMod.NPCs.NormalNPCs DisplayName.SetDefault("Piggy"); Main.npcFrameCount[NPC.type] = 5; Main.npcCatchable[NPC.type] = true; + NPCID.Sets.CountsAsCritter[NPC.type] = true; } public override void SetDefaults() diff --git a/NPCs/SunkenSea/BabyGhostBell.cs b/NPCs/SunkenSea/BabyGhostBell.cs index c228f913cb..a94a313226 100644 --- a/NPCs/SunkenSea/BabyGhostBell.cs +++ b/NPCs/SunkenSea/BabyGhostBell.cs @@ -21,6 +21,7 @@ namespace CalamityMod.NPCs.SunkenSea DisplayName.SetDefault("Baby Ghost Bell"); Main.npcFrameCount[NPC.type] = 4; Main.npcCatchable[NPC.type] = true; + NPCID.Sets.CountsAsCritter[NPC.type] = true; } public override void SetDefaults() @@ -47,10 +48,10 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SunkenSea, + //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SunkenSea, - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("Like their adult counterparts, they shimmer gently, and would make great sources of light if the prisms around them didn’t already do so. Maybe if there was a way to bring one with you.") + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("Like their adult counterparts, they shimmer gently, and would make great sources of light if the prisms around them didn’t already do so. Maybe if there was a way to bring one with you.") }); } diff --git a/NPCs/SunkenSea/SeaMinnow.cs b/NPCs/SunkenSea/SeaMinnow.cs index b2ed9bda30..34a785a348 100644 --- a/NPCs/SunkenSea/SeaMinnow.cs +++ b/NPCs/SunkenSea/SeaMinnow.cs @@ -15,6 +15,7 @@ namespace CalamityMod.NPCs.SunkenSea DisplayName.SetDefault("Sea Minnow"); Main.npcFrameCount[NPC.type] = 4; Main.npcCatchable[NPC.type] = true; + NPCID.Sets.CountsAsCritter[NPC.type] = true; } public override void SetDefaults() @@ -39,10 +40,10 @@ namespace CalamityMod.NPCs.SunkenSea public override void SetBestiary(BestiaryDatabase database, BestiaryEntry bestiaryEntry) { bestiaryEntry.Info.AddRange(new IBestiaryInfoElement[] { - //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SunkenSea, + //BestiaryDatabaseNPCsPopulator.CommonTags.SpawnConditions.Biomes.SunkenSea, - // Will move to localization whenever that is cleaned up. - new FlavorTextBestiaryInfoElement("While they are at the bottom of the food chain, they also make up eighty percent of the biomass in this sea. They nibble away at corpses that fall from the underground desert above.") + // Will move to localization whenever that is cleaned up. + new FlavorTextBestiaryInfoElement("While they are at the bottom of the food chain, they also make up eighty percent of the biomass in this sea. They nibble away at corpses that fall from the underground desert above.") }); } From 3788ec21ca8ced877b88305259370235e0f7589b Mon Sep 17 00:00:00 2001 From: DominicKarma <51094361+DominicKarma@users.noreply.github.com> Date: Wed, 1 Jun 2022 19:06:25 -0500 Subject: [PATCH 2/2] Transformed Cal's boss bar into a mod bar style --- CalamityMod.cs | 1 - Systems/UIManagementSystem.cs | 20 -------------------- UI/BossHealthBarManager.cs | 14 +++++++++----- 3 files changed, 9 insertions(+), 26 deletions(-) diff --git a/CalamityMod.cs b/CalamityMod.cs index fc6093dbb6..f942d11b3a 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -329,7 +329,6 @@ namespace CalamityMod BossRushEvent.Unload(); SchematicManager.Unload(); CustomLavaManagement.Unload(); - BossHealthBarManager.Unload(); DraedonStructures.Unload(); CooldownRegistry.Unload(); PlayerDashManager.Unload(); diff --git a/Systems/UIManagementSystem.cs b/Systems/UIManagementSystem.cs index cef6e2d679..dd4d2cbc55 100644 --- a/Systems/UIManagementSystem.cs +++ b/Systems/UIManagementSystem.cs @@ -29,16 +29,6 @@ namespace CalamityMod.Systems int mouseIndex = layers.FindIndex(layer => layer.Name == "Vanilla: Mouse Text"); if (mouseIndex != -1) { - layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Boss HP Bars", delegate () - { - if (Main.LocalPlayer.Calamity().drawBossHPBar) - { - BossHealthBarManager.Update(); - BossHealthBarManager.Draw(Main.spriteBatch); - } - return true; - }, InterfaceScaleType.None)); - layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Draedon Hologram", () => { LabHologramProjectorUI.Draw(Main.spriteBatch); @@ -60,16 +50,6 @@ namespace CalamityMod.Systems return true; }, InterfaceScaleType.Game)); - layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Boss HP Bars", delegate () - { - if (Main.LocalPlayer.Calamity().drawBossHPBar) - { - BossHealthBarManager.Update(); - BossHealthBarManager.Draw(Main.spriteBatch); - } - return true; - }, InterfaceScaleType.None)); - // Mode Indicator UI. layers.Insert(mouseIndex, new LegacyGameInterfaceLayer("Mode Indicator UI", delegate () { diff --git a/UI/BossHealthBarManager.cs b/UI/BossHealthBarManager.cs index 818e41c1db..e5acca6563 100644 --- a/UI/BossHealthBarManager.cs +++ b/UI/BossHealthBarManager.cs @@ -29,8 +29,10 @@ using System; using System.Collections.Generic; using System.Linq; using Terraria; +using Terraria.DataStructures; using Terraria.GameContent; using Terraria.GameContent.Events; +using Terraria.GameContent.UI.BigProgressBar; using Terraria.ID; using Terraria.ModLoader; @@ -61,7 +63,7 @@ namespace CalamityMod.UI That should be it -- ask if you have any questions! */ - public static class BossHealthBarManager + public class BossHealthBarManager : ModBossBarStyle { public struct BossEntityExtension { @@ -346,7 +348,7 @@ namespace CalamityMod.UI } #pragma warning restore IDE0028 // Simplify collection initialization - internal static void Unload() + public override void Unload() { BossMainHPBar = null; BossComboHPBar = null; @@ -360,7 +362,7 @@ namespace CalamityMod.UI SpecialHPRequirements = null; } - public static void Update() + public override void Update(IBigProgressBar currentBar, ref BigProgressBarInfo info) { for (int i = 0; i < Main.maxNPCs; i++) { @@ -411,7 +413,9 @@ namespace CalamityMod.UI Bars.Add(new BossHPUI(index, overridingName)); } - public static void Draw(SpriteBatch sb) + public override bool PreventDraw => true; + + public override void Draw(SpriteBatch spriteBatch, IBigProgressBar currentBar, BigProgressBarInfo info) { int startHeight = 100; int x = Main.screenWidth - 420; @@ -421,7 +425,7 @@ namespace CalamityMod.UI foreach (BossHPUI ui in Bars) { - ui.Draw(sb, x, y); + ui.Draw(spriteBatch, x, y); y -= BossHPUI.VerticalOffsetPerBar; } }