mirror of
https://github.com/YouHaveTrouble/YHTMod.git
synced 2026-05-11 21:56:54 +00:00
fix running without calamity installed
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace YHTMod.Changes;
|
||||
|
||||
[ExtendsFromMod("CalamityMod")]
|
||||
public class CalamityHelper {
|
||||
|
||||
public static readonly CalamityHelper Instance = new();
|
||||
|
||||
private static Dictionary<string, int> _bossIconIds;
|
||||
|
||||
private static Mod _calamity;
|
||||
|
||||
private CalamityHelper() {
|
||||
ModLoader.TryGetMod("CalamityMod", out Mod calamity);
|
||||
_calamity = calamity;
|
||||
if (_calamity == null) return;
|
||||
|
||||
_bossIconIds = new Dictionary<string, int> {
|
||||
{ "desert_scourge", ModContent.TryFind("CalamityMod", "LoreDesertScourge", out ModItem item1) ? item1.Type : -1 },
|
||||
{ "crabulon", ModContent.TryFind("CalamityMod", "LoreCrabulon", out ModItem item2) ? item2.Type : -1 },
|
||||
{ "perforators", ModContent.TryFind("CalamityMod", "LorePerforators", out ModItem item3) ? item3.Type : -1 },
|
||||
{ "hive_mind", ModContent.TryFind("CalamityMod", "LoreHiveMind", out ModItem item4) ? item4.Type : -1 },
|
||||
{ "slime_god", ModContent.TryFind("CalamityMod", "LoreSlimeGod", out ModItem item5) ? item5.Type : -1 }
|
||||
};
|
||||
}
|
||||
|
||||
public static int GetBossIconId(string bossKey) {
|
||||
return _bossIconIds.GetValueOrDefault(bossKey, -1);
|
||||
}
|
||||
|
||||
public static Mod GetCalamityMod() {
|
||||
return _calamity;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user