From a4cb45a32197571700a1fd1f02df7f15bc244b20 Mon Sep 17 00:00:00 2001 From: Mishiro Usui Date: Sat, 18 Nov 2023 03:36:09 +0000 Subject: [PATCH] Provi border variable adjustments for other mod support --- Graphics/Drawers/HolyInfernoDrawer.cs | 9 ++++----- NPCs/Providence/Providence.cs | 18 +++++++++++------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Graphics/Drawers/HolyInfernoDrawer.cs b/Graphics/Drawers/HolyInfernoDrawer.cs index c6f60867a5..b4b863bd81 100644 --- a/Graphics/Drawers/HolyInfernoDrawer.cs +++ b/Graphics/Drawers/HolyInfernoDrawer.cs @@ -19,16 +19,15 @@ namespace CalamityMod.Graphics.Drawers //Should only draw if not in the main menu, provi is active and the boolean for drawing the border is true. public override bool ShouldDraw => !Main.gameMenu && CalamityGlobalNPC.holyBoss != -1 && - Main.npc[CalamityGlobalNPC.holyBoss].active && (Main.npc[CalamityGlobalNPC.holyBoss].ModNPC as Providence).shouldDrawInfernoBorder; + Main.npc[CalamityGlobalNPC.holyBoss].active && Providence.shouldDrawInfernoBorder; #endregion #region Methods public override void DrawToTarget(SpriteBatch spriteBatch) { var npc = Main.npc[CalamityGlobalNPC.holyBoss]; - var provi = npc.ModNPC as Providence; - var borderStartEnd = provi.borderStartEnd; - if (borderStartEnd.Item1 > 0f && npc.HasValidTarget) + var borderDistance = Providence.borderRadius; + if (npc.HasValidTarget) { var target = Main.player[Main.myPlayer]; var holyInfernoIntensity = target.Calamity().holyInfernoFadeIntensity; @@ -42,7 +41,7 @@ namespace CalamityMod.Graphics.Drawers var shader = GameShaders.Misc["CalamityMod:HolyInfernoShader"].Shader; shader.Parameters["colorMult"].SetValue(Main.dayTime ? 7.35f : 7.65f); //I want you to know it took considerable restraint to deliberately misspell colour. shader.Parameters["time"].SetValue(Main.GlobalTimeWrappedHourly); - shader.Parameters["radius"].SetValue(borderStartEnd.Item2); + shader.Parameters["radius"].SetValue(borderDistance); shader.Parameters["anchorPoint"].SetValue(npc.Center); shader.Parameters["screenPosition"].SetValue(Main.screenPosition); shader.Parameters["screenSize"].SetValue(Main.ScreenSize.ToVector2()); diff --git a/NPCs/Providence/Providence.cs b/NPCs/Providence/Providence.cs index 69fc4c669f..1b0547687b 100644 --- a/NPCs/Providence/Providence.cs +++ b/NPCs/Providence/Providence.cs @@ -89,10 +89,10 @@ namespace CalamityMod.NPCs.Providence private int healTimer = 0; internal bool challenge = Main.expertMode; //Used to determine if Profaned Soul Crystal should drop, couldn't figure out mp mems always dropping it so challenge is singleplayer only. internal bool hasTakenDaytimeDamage = false; - public bool shouldDrawInfernoBorder = true; //This is only here for other mods to disable it if they don't want it drawing. + public static bool shouldDrawInfernoBorder = true; //This is only here for other mods to disable it if they don't want it drawing. public bool Dying = false; public int DeathAnimationTimer; - public Tuple borderStartEnd = new (2800f, 3000f); + public static float borderRadius = 3000f; //Sounds public static readonly SoundStyle SpawnSound = new("CalamityMod/Sounds/Custom/Providence/ProvidenceSpawn") { Volume = 1.2f }; @@ -190,8 +190,7 @@ namespace CalamityMod.NPCs.Providence writer.Write(SoundWarningLevel); writer.Write(Dying); writer.Write(DeathAnimationTimer); - writer.Write(borderStartEnd.Item1); - writer.Write(borderStartEnd.Item2); + writer.Write(borderRadius); writer.Write(shouldDrawInfernoBorder); for (int i = 0; i < 4; i++) writer.Write(NPC.Calamity().newAI[i]); @@ -218,7 +217,7 @@ namespace CalamityMod.NPCs.Providence SoundWarningLevel = reader.ReadSingle(); Dying = reader.ReadBoolean(); DeathAnimationTimer = reader.ReadInt32(); - borderStartEnd = new (reader.ReadSingle(), reader.ReadSingle()); + borderRadius = reader.ReadSingle(); shouldDrawInfernoBorder = reader.ReadBoolean(); for (int i = 0; i < 4; i++) @@ -234,6 +233,10 @@ namespace CalamityMod.NPCs.Providence public override void AI() { + // Set the border drawing to true if it isn't set to true + // Can happen when another mod sets to false for a difficulty and that difficulty is then toggled off. + shouldDrawInfernoBorder = true; + CalamityGlobalNPC calamityGlobalNPC = NPC.Calamity(); // whoAmI variable for Guardians and other things @@ -1857,9 +1860,10 @@ namespace CalamityMod.NPCs.Providence } float drawFireDistanceStart = maxDistance - 800f; - float previousBorderEnd = borderStartEnd.Item2; + float previousBorderEnd = borderRadius; float clampedDistance = MathHelper.Clamp(maxDistance, previousBorderEnd - 10, previousBorderEnd + 10); - borderStartEnd = new (drawFireDistanceStart, clampedDistance); + // Only set the border distance if it's not called from playermisceffects, that way it has mod compatability + borderRadius = clampedDistance; return Utils.GetLerpValue(drawFireDistanceStart, clampedDistance, distanceToTarget, true); }