ugly but extensible mod tile avoidance

This commit is contained in:
Ozzatron committed 2020-12-12 02:48:57 -05:00
1 parent 48a53d5fbc
commit a67496edb2
2 files changed
+39 -22

No files matched your search

+2 -2
View File
@@ -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();
+37 -20
View File
@@ -16,6 +16,34 @@ namespace CalamityMod.World
{
public static class DraedonStructures
{
private static int[] otherModTilesToAvoid;
internal static void Load()
{
IList<int> avoid = new List<int>(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