Decompiled source of BossFinder v1.0.0

BossFinder.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BossFinder")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BossFinder")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("39c603ca-d1d8-430b-91b2-385a774e3baf")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BossFinder;

[BepInPlugin("lizzardfyll.bossfinder", "Boss Finder", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BossFinderPlugin : BaseUnityPlugin
{
	public class RequirementData
	{
		public string Item { get; set; }

		public int Amount { get; set; }
	}

	public class BossData
	{
		public string LocationName { get; set; }

		public string PinNameKey { get; set; }

		public string ItemName { get; set; }

		public string DisplayNameKey { get; set; }

		public string DescriptionKey { get; set; }

		public string ClonePrefab { get; set; }

		public List<RequirementData> Requirements { get; set; }
	}

	public const string PluginGUID = "lizzardfyll.bossfinder";

	public const string PluginName = "Boss Finder";

	public const string PluginVersion = "1.0.0";

	private static ConfigEntry<string> _selectedLanguage;

	private static ConfigEntry<string> _selectedBoss;

	private static string _currentLanguage = "English";

	private static Dictionary<string, BossData> Bosses = new Dictionary<string, BossData>();

	private static Dictionary<string, Dictionary<string, string>> _translations = new Dictionary<string, Dictionary<string, string>>();

	private void Awake()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Expected O, but got Unknown
		SetupLocalizations();
		InitBossesData();
		_selectedLanguage = ((BaseUnityPlugin)this).Config.Bind<string>("Language", "Language", "English", new ConfigDescription("Select language / Выберите язык (requires restart / требует перезапуска)", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "English", "Русский" }), Array.Empty<object>()));
		_currentLanguage = _selectedLanguage.Value;
		_selectedLanguage.SettingChanged += delegate
		{
			_currentLanguage = _selectedLanguage.Value;
			Logger.LogInfo((object)("Language changed to: " + _currentLanguage));
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, "Language changed. Restart the game to apply / Язык изменен. Перезапустите игру для применения", 0, (Sprite)null);
			}
		};
		string[] bossNames = GetBossNames();
		_selectedBoss = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Show Boss Locations", Translate("None"), new ConfigDescription(Translate("Select a boss to reveal their altar locations on the map"), (AcceptableValueBase)(object)new AcceptableValueList<string>(bossNames), Array.Empty<object>()));
		_selectedBoss.SettingChanged += delegate
		{
			if (_selectedBoss.Value != Translate("None"))
			{
				ShowBossLocations(_selectedBoss.Value);
			}
		};
		PrefabManager.OnVanillaPrefabsAvailable += CreateItems;
		Harmony.CreateAndPatchAll(typeof(PlayerConsumePatch), (string)null);
		Logger.LogInfo((object)"Boss Finder mod loaded!");
	}

	private void SetupLocalizations()
	{
		Dictionary<string, string> dictionary = new Dictionary<string, string>();
		dictionary["None"] = "None";
		dictionary["Select a boss to reveal their altar locations on the map"] = "Select a boss to reveal their altar locations on the map";
		dictionary["Eikthyr"] = "Eikthyr";
		dictionary["Elder"] = "Elder";
		dictionary["Bonemass"] = "Bonemass";
		dictionary["Moder"] = "Moder";
		dictionary["Yagluth"] = "Yagluth";
		dictionary["Queen"] = "Queen";
		dictionary["Fader"] = "Fader";
		dictionary["Eikthyr's Map"] = "Eikthyr's Map";
		dictionary["Elder's Map"] = "Elder's Map";
		dictionary["Bonemass's Map"] = "Bonemass's Map";
		dictionary["Moder's Map"] = "Moder's Map";
		dictionary["Yagluth's Map"] = "Yagluth's Map";
		dictionary["Queen's Map"] = "Queen's Map";
		dictionary["Fader's Map"] = "Fader's Map";
		dictionary["Reveals all Eikthyr altar locations on the map"] = "Reveals all Eikthyr altar locations on the map";
		dictionary["Reveals all Elder altar locations on the map"] = "Reveals all Elder altar locations on the map";
		dictionary["Reveals all Bonemass altar locations on the map"] = "Reveals all Bonemass altar locations on the map";
		dictionary["Reveals all Moder altar locations on the map"] = "Reveals all Moder altar locations on the map";
		dictionary["Reveals all Yagluth altar locations on the map"] = "Reveals all Yagluth altar locations on the map";
		dictionary["Reveals all Queen altar locations on the map"] = "Reveals all Queen altar locations on the map";
		dictionary["Reveals all Fader altar locations on the map"] = "Reveals all Fader altar locations on the map";
		dictionary[" locations revealed on map!"] = " locations revealed on map!";
		dictionary["No "] = "No ";
		dictionary[" locations found in this world!"] = " locations found in this world!";
		dictionary["Eikthyr Altar"] = "Eikthyr";
		dictionary["Elder Altar"] = "Elder";
		dictionary["Bonemass Altar"] = "Bonemass";
		dictionary["Moder Altar"] = "Moder";
		dictionary["Yagluth Altar"] = "Yagluth";
		dictionary["Queen Altar"] = "Queen";
		dictionary["Fader Altar"] = "Fader";
		_translations["English"] = dictionary;
		Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
		dictionary2["None"] = "Нет";
		dictionary2["Select a boss to reveal their altar locations on the map"] = "Выберите босса для открытия его алтарей на карте";
		dictionary2["Eikthyr"] = "Эйктюр";
		dictionary2["Elder"] = "Древний";
		dictionary2["Bonemass"] = "Масса костей";
		dictionary2["Moder"] = "Матерь";
		dictionary2["Yagluth"] = "Ялгут";
		dictionary2["Queen"] = "Королева";
		dictionary2["Fader"] = "Прародитель";
		dictionary2["Eikthyr's Map"] = "Карта Эйктюр";
		dictionary2["Elder's Map"] = "Карта Древний";
		dictionary2["Bonemass's Map"] = "Карта Масса костей";
		dictionary2["Moder's Map"] = "Карта Матерь";
		dictionary2["Yagluth's Map"] = "Карта Ялгут";
		dictionary2["Queen's Map"] = "Карта Королева";
		dictionary2["Fader's Map"] = "Карта Прародитель";
		dictionary2["Reveals all Eikthyr altar locations on the map"] = "Покажет все точки для призыва босса Эйктюр на вашей карте";
		dictionary2["Reveals all Elder altar locations on the map"] = "Покажет все точки для призыва босса Древний на вашей карте";
		dictionary2["Reveals all Bonemass altar locations on the map"] = "Покажет все точки для призыва босса Масса костей на вашей карте";
		dictionary2["Reveals all Moder altar locations on the map"] = "Покажет все точки для призыва босса Матерь на вашей карте";
		dictionary2["Reveals all Yagluth altar locations on the map"] = "Покажет все точки для призыва босса Ялгут на вашей карте";
		dictionary2["Reveals all Queen altar locations on the map"] = "Покажет все точки для призыва босса Королева на вашей карте";
		dictionary2["Reveals all Fader altar locations on the map"] = "Покажет все точки для призыва босса Прародитель на вашей карте";
		dictionary2[" locations revealed on map!"] = " локации открыты на карте!";
		dictionary2["No "] = "Нет ";
		dictionary2[" locations found in this world!"] = " локаций найдено в этом мире!";
		dictionary2["Eikthyr Altar"] = "Эйктюр";
		dictionary2["Elder Altar"] = "Древний";
		dictionary2["Bonemass Altar"] = "Масса костей";
		dictionary2["Moder Altar"] = "Матерь";
		dictionary2["Yagluth Altar"] = "Ялгут";
		dictionary2["Queen Altar"] = "Королева";
		dictionary2["Fader Altar"] = "Прародитель";
		_translations["Русский"] = dictionary2;
	}

	private static string Translate(string key)
	{
		if (_translations.ContainsKey(_currentLanguage) && _translations[_currentLanguage].ContainsKey(key))
		{
			return _translations[_currentLanguage][key];
		}
		if (_translations.ContainsKey("English") && _translations["English"].ContainsKey(key))
		{
			return _translations["English"][key];
		}
		return key;
	}

	private void InitBossesData()
	{
		BossData bossData = new BossData();
		bossData.LocationName = "Eikthyrnir";
		bossData.PinNameKey = "Eikthyr Altar";
		bossData.ItemName = "EikthyrMap";
		bossData.DisplayNameKey = "Eikthyr's Map";
		bossData.DescriptionKey = "Reveals all Eikthyr altar locations on the map";
		bossData.ClonePrefab = "TrophyEikthyr";
		bossData.Requirements = new List<RequirementData>();
		bossData.Requirements.Add(new RequirementData
		{
			Item = "TrophyDeer",
			Amount = 2
		});
		bossData.Requirements.Add(new RequirementData
		{
			Item = "Coins",
			Amount = 200
		});
		Bosses["Eikthyr"] = bossData;
		BossData bossData2 = new BossData();
		bossData2.LocationName = "GDKing";
		bossData2.PinNameKey = "Elder Altar";
		bossData2.ItemName = "ElderMap";
		bossData2.DisplayNameKey = "Elder's Map";
		bossData2.DescriptionKey = "Reveals all Elder altar locations on the map";
		bossData2.ClonePrefab = "TrophyTheElder";
		bossData2.Requirements = new List<RequirementData>();
		bossData2.Requirements.Add(new RequirementData
		{
			Item = "AncientSeed",
			Amount = 3
		});
		bossData2.Requirements.Add(new RequirementData
		{
			Item = "Coins",
			Amount = 250
		});
		Bosses["Elder"] = bossData2;
		BossData bossData3 = new BossData();
		bossData3.LocationName = "Bonemass";
		bossData3.PinNameKey = "Bonemass Altar";
		bossData3.ItemName = "BonemassMap";
		bossData3.DisplayNameKey = "Bonemass's Map";
		bossData3.DescriptionKey = "Reveals all Bonemass altar locations on the map";
		bossData3.ClonePrefab = "TrophyBonemass";
		bossData3.Requirements = new List<RequirementData>();
		bossData3.Requirements.Add(new RequirementData
		{
			Item = "WitheredBone",
			Amount = 10
		});
		bossData3.Requirements.Add(new RequirementData
		{
			Item = "Coins",
			Amount = 300
		});
		Bosses["Bonemass"] = bossData3;
		BossData bossData4 = new BossData();
		bossData4.LocationName = "Dragonqueen";
		bossData4.PinNameKey = "Moder Altar";
		bossData4.ItemName = "ModerMap";
		bossData4.DisplayNameKey = "Moder's Map";
		bossData4.DescriptionKey = "Reveals all Moder altar locations on the map";
		bossData4.ClonePrefab = "TrophyDragonQueen";
		bossData4.Requirements = new List<RequirementData>();
		bossData4.Requirements.Add(new RequirementData
		{
			Item = "DragonEgg",
			Amount = 3
		});
		bossData4.Requirements.Add(new RequirementData
		{
			Item = "Coins",
			Amount = 400
		});
		Bosses["Moder"] = bossData4;
		BossData bossData5 = new BossData();
		bossData5.LocationName = "GoblinKing";
		bossData5.PinNameKey = "Yagluth Altar";
		bossData5.ItemName = "YagluthMap";
		bossData5.DisplayNameKey = "Yagluth's Map";
		bossData5.DescriptionKey = "Reveals all Yagluth altar locations on the map";
		bossData5.ClonePrefab = "TrophyGoblinKing";
		bossData5.Requirements = new List<RequirementData>();
		bossData5.Requirements.Add(new RequirementData
		{
			Item = "GoblinTotem",
			Amount = 5
		});
		bossData5.Requirements.Add(new RequirementData
		{
			Item = "Coins",
			Amount = 500
		});
		Bosses["Yagluth"] = bossData5;
		BossData bossData6 = new BossData();
		bossData6.LocationName = "Mistlands_DvergrBossEntrance1";
		bossData6.PinNameKey = "Queen Altar";
		bossData6.ItemName = "QueenMap";
		bossData6.DisplayNameKey = "Queen's Map";
		bossData6.DescriptionKey = "Reveals all Queen altar locations on the map";
		bossData6.ClonePrefab = "TrophySeekerQueen";
		bossData6.Requirements = new List<RequirementData>();
		bossData6.Requirements.Add(new RequirementData
		{
			Item = "TrophySeekerBrute",
			Amount = 3
		});
		bossData6.Requirements.Add(new RequirementData
		{
			Item = "Coins",
			Amount = 500
		});
		Bosses["Queen"] = bossData6;
		BossData bossData7 = new BossData();
		bossData7.LocationName = "FaderLocation";
		bossData7.PinNameKey = "Fader Altar";
		bossData7.ItemName = "FaderMap";
		bossData7.DisplayNameKey = "Fader's Map";
		bossData7.DescriptionKey = "Reveals all Fader altar locations on the map";
		bossData7.ClonePrefab = "TrophyFader";
		bossData7.Requirements = new List<RequirementData>();
		bossData7.Requirements.Add(new RequirementData
		{
			Item = "Bell",
			Amount = 1
		});
		bossData7.Requirements.Add(new RequirementData
		{
			Item = "Coins",
			Amount = 500
		});
		Bosses["Fader"] = bossData7;
	}

	private string[] GetBossNames()
	{
		List<string> list = new List<string> { Translate("None") };
		foreach (KeyValuePair<string, BossData> boss in Bosses)
		{
			list.Add(Translate(boss.Key));
		}
		return list.ToArray();
	}

	private void CreateItems()
	{
		foreach (KeyValuePair<string, BossData> boss in Bosses)
		{
			CreateBossItem(boss.Value);
		}
		PrefabManager.OnVanillaPrefabsAvailable -= CreateItems;
		Logger.LogInfo((object)"All boss map items created!");
	}

	private void CreateBossItem(BossData bossData)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Expected O, but got Unknown
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Expected O, but got Unknown
		CustomItem val = new CustomItem(bossData.ItemName, bossData.ClonePrefab);
		val.ItemDrop.m_itemData.m_shared.m_name = Translate(bossData.DisplayNameKey);
		val.ItemDrop.m_itemData.m_shared.m_description = Translate(bossData.DescriptionKey);
		val.ItemDrop.m_itemData.m_shared.m_weight = 0.1f;
		val.ItemDrop.m_itemData.m_shared.m_maxStackSize = 1;
		val.ItemDrop.m_itemData.m_shared.m_itemType = (ItemType)2;
		ItemManager.Instance.AddItem(val);
		RecipeConfig val2 = new RecipeConfig();
		val2.Name = "Recipe_" + bossData.ItemName;
		val2.Item = bossData.ItemName;
		val2.Amount = 1;
		val2.CraftingStation = "piece_workbench";
		val2.MinStationLevel = 1;
		val2.Enabled = true;
		foreach (RequirementData requirement in bossData.Requirements)
		{
			val2.AddRequirement(requirement.Item, requirement.Amount, 0);
		}
		ItemManager.Instance.AddRecipe(new CustomRecipe(val2));
		Logger.LogInfo((object)("Created " + bossData.DisplayNameKey));
	}

	public static void ShowBossLocations(string bossName)
	{
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		string text = null;
		foreach (KeyValuePair<string, BossData> boss in Bosses)
		{
			string text2 = Translate(boss.Key);
			if (text2 == bossName || boss.Key == bossName)
			{
				text = boss.Key;
				break;
			}
		}
		if (text == null || !Bosses.ContainsKey(text))
		{
			return;
		}
		BossData bossData = Bosses[text];
		if ((Object)(object)ZoneSystem.instance == (Object)null || (Object)(object)Minimap.instance == (Object)null)
		{
			return;
		}
		string text3 = Translate(bossData.PinNameKey);
		List<LocationInstance> list = new List<LocationInstance>();
		if (ZoneSystem.instance.FindLocations(bossData.LocationName, ref list))
		{
			foreach (LocationInstance item in list)
			{
				Minimap.instance.DiscoverLocation(item.m_position, (PinType)9, text3, true);
			}
			Logger.LogInfo((object)$"Added {list.Count} {text3} locations to map");
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, "<color=orange>" + text3 + "</color> locations revealed on map!", 0, (Sprite)null);
			}
		}
		else
		{
			Logger.LogWarning((object)("No " + bossData.LocationName + " locations found!"));
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, "<color=red>No " + text3 + " locations found in this world!</color>", 0, (Sprite)null);
			}
		}
	}
}
[HarmonyPatch(typeof(Player))]
public static class PlayerConsumePatch
{
	[CompilerGenerated]
	private sealed class <ShowLocationsWithDelay>d__2 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public string bossName;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ShowLocationsWithDelay>d__2(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				BossFinderPlugin.ShowBossLocations(bossName);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static Dictionary<string, string> ItemToBoss = new Dictionary<string, string>
	{
		{ "Eikthyr's Map", "Eikthyr" },
		{ "Elder's Map", "Elder" },
		{ "Bonemass's Map", "Bonemass" },
		{ "Moder's Map", "Moder" },
		{ "Yagluth's Map", "Yagluth" },
		{ "Queen's Map", "Queen" },
		{ "Fader's Map", "Fader" },
		{ "Карта Эйктюр", "Eikthyr" },
		{ "Карта Древний", "Elder" },
		{ "Карта Масса костей", "Bonemass" },
		{ "Карта Матерь", "Moder" },
		{ "Карта Ялгут", "Yagluth" },
		{ "Карта Королева", "Queen" },
		{ "Карта Прародитель", "Fader" }
	};

	[HarmonyPrefix]
	[HarmonyPatch("ConsumeItem")]
	private static void OnConsumeItem(Player __instance, Inventory inventory, ItemData item, bool checkWorldLevel)
	{
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || item == null)
		{
			return;
		}
		string name = item.m_shared.m_name;
		if (ItemToBoss.ContainsKey(name))
		{
			if (InventoryGui.IsVisible())
			{
				InventoryGui.instance.Hide();
			}
			string bossName = ItemToBoss[name];
			((MonoBehaviour)__instance).StartCoroutine(ShowLocationsWithDelay(bossName));
		}
	}

	[IteratorStateMachine(typeof(<ShowLocationsWithDelay>d__2))]
	private static IEnumerator ShowLocationsWithDelay(string bossName)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ShowLocationsWithDelay>d__2(0)
		{
			bossName = bossName
		};
	}
}