diff --git a/CalamityMod.cs b/CalamityMod.cs index 4cb0495871..4b6a186b5e 100644 --- a/CalamityMod.cs +++ b/CalamityMod.cs @@ -138,9 +138,8 @@ namespace CalamityMod ILChanges.Load(); BossRushEvent.Load(); - BossHealthBarManager.Load(this); - + DraedonStructures.Load(); CalamityLists.LoadLists(); SetupVanillaDR(); SetupBossKillTimes(); @@ -267,6 +266,7 @@ namespace CalamityMod BossRushEvent.Unload(); SchematicManager.Unload(); BossHealthBarManager.Unload(); + DraedonStructures.Unload(); TileFraming.Unload(); diff --git a/World/DraedonStructures.cs b/World/DraedonStructures.cs index 2afdc92e5b..3402eab80b 100644 --- a/World/DraedonStructures.cs +++ b/World/DraedonStructures.cs @@ -16,6 +16,34 @@ namespace CalamityMod.World { public static class DraedonStructures { + private static int[] otherModTilesToAvoid; + + internal static void Load() + { + IList avoid = new List(16); + + // Mod of Redemption's labs use modded blocks, but must still be avoided. + Mod mor = ModLoader.GetMod("Redemption"); + if (mor != null) + { + // Thanks to Hallam to providing these tile names. + string[] redemptionAvoidTiles = new string[] + { + "LabTileUnsafe", + "OvergrownLabTile" + }; + foreach (string tileName in redemptionAvoidTiles) + avoid.Add(mor.TileType(tileName)); + } + + otherModTilesToAvoid = avoid.ToArray(); + } + + internal static void Unload() + { + otherModTilesToAvoid = null; + } + public static bool ShouldAvoidLocation(Point placementPoint, bool careAboutLava = true) { Tile tile = CalamityUtils.ParanoidTileRetrieval(placementPoint.X, placementPoint.Y); @@ -39,27 +67,16 @@ namespace CalamityMod.World { return true; } - // Avoid Thorium's Blood Chamber (where you summon Viscount) - if (tile.type == TileID.StoneSlab || - tile.wall == WallID.StoneSlab) - { - return true; - } - // As well as MoD's special labs. - Mod modOfRedemption = ModLoader.GetMod("Redemption"); - if (modOfRedemption != null) - { - // Thanks to Hallam to providing these tile names. - string[] tilesToAvoid = new string[] - { - "LabTileUnsafe", - "OvergrownLabTile" - }; - if (tilesToAvoid.Any(tileTypeName => tile.type == modOfRedemption.TileType(tileTypeName))) - return true; - } - return false; + // + // Below this line: Avoiding other mod worldgen. + // + + // Avoid Thorium's Blood Chamber (where you summon Viscount). This is done separately because it uses vanilla tiles. + if (tile.type == TileID.StoneSlab || tile.wall == WallID.StoneSlab) + return true; + // Avoid all other registered modded tiles to avoid. + return otherModTilesToAvoid.Any(id => tile.type == id); } #region Workshop