From 8dc7ea7c94c23f8d99bba02a9393063cbcbe95ec Mon Sep 17 00:00:00 2001 From: Dominic Date: Sun, 5 Jun 2022 19:53:45 -0500 Subject: [PATCH] Fixed Abyss/Subworld Library problems --- BiomeManagers/AbyssLayer1Biome.cs | 4 ++++ CalamityMod.cs | 3 +++ ModSupport/WeakReferenceSupport.cs | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/BiomeManagers/AbyssLayer1Biome.cs b/BiomeManagers/AbyssLayer1Biome.cs index 45bdcffcfd..d7f4185e02 100644 --- a/BiomeManagers/AbyssLayer1Biome.cs +++ b/BiomeManagers/AbyssLayer1Biome.cs @@ -32,6 +32,10 @@ namespace CalamityMod.BiomeManagers } playerYTileCoords = point.Y; + + if (WeakReferenceSupport.InAnySubworld()) + return false; + return point.Y > (Main.rockLayer - y * 0.05) && !player.lavaWet && !player.honeyWet && diff --git a/CalamityMod.cs b/CalamityMod.cs index f942d11b3a..cee496e12a 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -131,6 +131,7 @@ namespace CalamityMod internal Mod summonersAssociation = null; internal Mod thorium = null; internal Mod varia = null; + internal Mod subworldLibrary = null; #region Load public override void Load() @@ -172,6 +173,8 @@ namespace CalamityMod ModLoader.TryGetMod("ThoriumMod", out thorium); varia = null; ModLoader.TryGetMod("Varia", out varia); + subworldLibrary = null; + ModLoader.TryGetMod("SubworldLibrary", out subworldLibrary); // Initialize the EnemyStats struct as early as it is safe to do so NPCStats.Load(); diff --git a/ModSupport/WeakReferenceSupport.cs b/ModSupport/WeakReferenceSupport.cs index 6f1cb3c2dc..e472f7109b 100644 --- a/ModSupport/WeakReferenceSupport.cs +++ b/ModSupport/WeakReferenceSupport.cs @@ -213,6 +213,24 @@ namespace CalamityMod // Wrapper function to add summon items to other mods' bosses for Boss Checklist. private static void AddSummons(Mod bossChecklist, string mod, string bossName, List summons) => bossChecklist.Call("AddToBossSpawnItems", mod, bossName, summons); + // Wrapper function to detect if a subworld is in use for Subworld Library. + internal static bool InAnySubworld() + { + if (CalamityMod.Instance.subworldLibrary is null) + return false; + + foreach (Mod mod in ModLoader.Mods) + { + if (mod.Name.Equals(CalamityMod.Instance.subworldLibrary.Name)) + continue; + + bool anySubworldForMod = (CalamityMod.Instance.subworldLibrary.Call("AnyActive", mod) as bool?) ?? false; + if (anySubworldForMod) + return true; + } + return false; + } + /// /// 1.0 = King Slime
/// 2.0 = Eye of Cthulhu