Decompiled source of UnderTheRadar v3.1.6

Kits_Bitz.Under_The_Radar.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using On;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Kits_Bitz.Under_The_Radar")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Under The Radar")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5e52ed0e-c58f-4ee8-b415-4b969bef0e08")]
[assembly: AssemblyFileVersion("3.1.6.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.1.6.0")]
[module: UnverifiableCode]
namespace Kits_Bitz.Under_The_Radar;

internal class RadarPinComponent : MonoBehaviour
{
	private string _pinName;

	private Vector2 _radius;

	private float _iconSize;

	private Sprite _itemIcon;

	private PinData _pinData;

	public void Create(bool pinText, string itemName, float radius, float iconSize, Sprite itemIcon)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		if (pinText)
		{
			_pinName = itemName.Replace("(Clone)", "").Replace("piece_", "").Replace("MineRock_", "")
				.Replace("Mistlands_", "");
		}
		else
		{
			_pinName = "";
		}
		_radius = new Vector2(radius, radius + 10f);
		_iconSize = iconSize;
		_itemIcon = itemIcon;
		_pinData = null;
	}

	private void Update()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if (Object.op_Implicit((Object)(object)localPlayer))
		{
			Vector3 val = ((Component)localPlayer).transform.position - ((Component)this).transform.position;
			if (_pinData == null && ((Vector3)(ref val)).magnitude < _radius.x)
			{
				_pinData = Minimap.instance.AddPin(((Component)this).transform.position, (PinType)8, _pinName, false, false, 0L, "");
				_pinData.m_icon = _itemIcon;
			}
			else if (_pinData != null && ((Vector3)(ref val)).magnitude > _radius.y)
			{
				Minimap.instance.RemovePin(_pinData);
				_pinData = null;
			}
			if (_pinData != null)
			{
				_pinData.m_pos = ((Component)this).transform.position;
			}
		}
	}

	private void OnDestroy()
	{
		if (_pinData != null)
		{
			try
			{
				Minimap.instance.RemovePin(_pinData);
				_pinData = null;
			}
			catch
			{
			}
		}
	}
}
[BepInPlugin("Kits_Bitz.UnderTheRadar", "UnderTheRadar", "3.1.6")]
[BepInProcess("valheim.exe")]
public class UnderTheRadarPlugin : BaseUnityPlugin
{
	public static ConfigEntry<bool> _enabled;

	public static ConfigEntry<bool> _pintext;

	public static ConfigEntry<bool> _enablelocations;

	public static ConfigEntry<string> _locations;

	public static ConfigEntry<bool> _enablepickables;

	public static ConfigEntry<string> _pickables;

	public static ConfigEntry<bool> _enablecritters;

	public static ConfigEntry<string> _critters;

	public static ConfigEntry<bool> _enableores;

	public static ConfigEntry<string> _ores;

	public static ConfigEntry<float> _radius;

	public static ConfigEntry<float> _iconSize;

	public static ConfigEntry<bool> _udrdebug;

	public bool Enabled;

	public string[] Locations;

	public string[] Pickables;

	public string[] Critters;

	public string[] Ores;

	public bool EnableRooms;

	public bool EnableCritters;

	public bool EnableLocations;

	public bool EnablePickables;

	public bool EnableOres;

	public float Radius;

	public float IconSize;

	public bool udrDebug;

	public bool PinText;

	public static string ConfigPath { get; }

	private void Awake()
	{
		//IL_054d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: Expected O, but got Unknown
		//IL_055e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0568: Expected O, but got Unknown
		//IL_056f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0579: Expected O, but got Unknown
		//IL_0580: Unknown result type (might be due to invalid IL or missing references)
		//IL_058a: Expected O, but got Unknown
		//IL_0591: Unknown result type (might be due to invalid IL or missing references)
		//IL_059b: Expected O, but got Unknown
		//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ac: Expected O, but got Unknown
		//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bd: Expected O, but got Unknown
		//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ce: Expected O, but got Unknown
		//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05df: Expected O, but got Unknown
		//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f0: Expected O, but got Unknown
		//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0601: Expected O, but got Unknown
		//IL_0608: Unknown result type (might be due to invalid IL or missing references)
		//IL_0612: Expected O, but got Unknown
		//IL_0619: Unknown result type (might be due to invalid IL or missing references)
		//IL_0623: Expected O, but got Unknown
		((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
		_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Turn me on...");
		_pintext = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PinText", true, "Turn on Pin Text...");
		_udrdebug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "udrDebug", false, "Enable debugging.  This will show you what icons are mapped to the game objects, amongst other things.");
		_radius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Radius", 70f, "The radius of detection. Default is 70 and Max is 150...");
		_iconSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "IconSize", 64f, "The size of icons on minimap (64 - default size, 32 for small is good).");
		_enablelocations = ((BaseUnityPlugin)this).Config.Bind<bool>("Items To Configure", "1.1 Locations", true, "Enable Locations");
		_locations = ((BaseUnityPlugin)this).Config.Bind<string>("Items To Configure", "1.2 Locations", string.Join(",", "SunkenCrypt", "Crypt", "MountainCave", "Vendor", "MudPile", "TrollCave", "Hut", "Cabin", "House", "Tower", "Ruin", "Dolmen", "Ship", "Grave", "Well", "Camp", "FireHole", "DrakeNest", "TarPit", "Spawner", "Rune", "Henge", "Village", "Eikthyr", "GDKing", "Bonemass", "GoblinKing", "DragonQueen", "SeekerQueen", "InfestedTree", "RoadPost", "Excavation", "LightHouse", "Fortress", "DvergrTown", "DvergrBoss", "altar_crystal", "YggdrasilRoot", "SapCollector", "Knarr"), "Locations to show on minimap.");
		_enablepickables = ((BaseUnityPlugin)this).Config.Bind<bool>("Items To Configure", "2.1 Pickables", true, "Enable Pickables");
		_pickables = ((BaseUnityPlugin)this).Config.Bind<string>("Items To Configure", "2.2 Pickables", string.Join(",", "Mushroom", "Turnip", "Carrot", "Raspberry", "Blueberry", "Thistle", "Chitin", "Crystal", "Cloudberry", "Barley", "Flax", "Onion", "SurtlingCore", "Totem", "BlackCore"), "Pickables to show on minimap.");
		_enablecritters = ((BaseUnityPlugin)this).Config.Bind<bool>("Items To Configure", "3.1 Critters", true, "Enable Critters");
		_critters = ((BaseUnityPlugin)this).Config.Bind<string>("Items To Configure", "3.2 Critters", string.Join(",", "Fish", "Beehive", "Serpent", "Leviathan", "Golem", "Troll", "Wraith", "Abomination", "Fenring", "Boar", "Deer", "Neck", "Wolf", "Hatchling", "Deathsquito", "Lox", "BlobTar", "Blob", "BlobElite", "Leech", "Draugr", "Surtling", "Chicken", "Hare", "Gjall", "Seeker", "Tick", "Dverger", "Bat"), "Critters to show on minimap.");
		_enableores = ((BaseUnityPlugin)this).Config.Bind<bool>("Items To Configure", "4.1 Ores", true, "Enable Ores");
		_ores = ((BaseUnityPlugin)this).Config.Bind<string>("Items To Configure", "4.2 Ores", string.Join(",", "Tin", "Copper", "Silver", "Iron", "Obsidian", "Sword", "Giant_Helmet", "Giant_Ribs", "Giant_Skull"), "Ores to show on minimap.");
		((BaseUnityPlugin)this).Config.Save();
		Reload();
		((BaseUnityPlugin)this).Config.SettingChanged += ReloadSettings;
		if (Enabled)
		{
			ObjectDB.Awake += new hook_Awake(ObjectDBAwakeHook);
			Destructible.Awake += new hook_Awake(DestructibleAwakeHook);
			DropOnDestroyed.Awake += new hook_Awake(DropOnDestroyedAwakeHook);
			Pickable.Awake += new hook_Awake(PickableAwakeHook);
			Pickable.SetPicked += new hook_SetPicked(PickableSetPickedHook);
			Location.Awake += new hook_Awake(LocationAwakeHook);
			Leviathan.Awake += new hook_Awake(LeviathanAwakeHook);
			Fish.Start += new hook_Start(FishStartHook);
			Character.Awake += new hook_Awake(CharacterAwakeHook);
			Beehive.Awake += new hook_Awake(BeehiveAwakeHook);
			ResourceRoot.Awake += new hook_Awake(ResourceRootAwakeHook);
			SapCollector.Awake += new hook_Awake(SapCollectorAwakeHook);
			Room.Awake += new hook_Awake(RoomAwakeHook);
		}
	}

	private void OnDestroy()
	{
		((BaseUnityPlugin)this).Logger.LogWarning((object)"Destroying UnderTheRadar plugin");
	}

	public void ReloadSettings(object sender, SettingChangedEventArgs arg)
	{
		((BaseUnityPlugin)this).Config.Save();
		if (_radius.Value >= 10f)
		{
			Reload();
		}
	}

	public void Reload()
	{
		Enabled = _enabled.Value;
		PinText = _pintext.Value;
		EnableLocations = _enablelocations.Value;
		if (!_enablelocations.Value)
		{
			Array.Resize(ref Locations, 0);
		}
		else
		{
			Locations = (from s in _locations.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
				select s.Trim()).Distinct().ToArray();
		}
		EnablePickables = _enablepickables.Value;
		if (!_enablepickables.Value)
		{
			Array.Resize(ref Pickables, 0);
		}
		else
		{
			Pickables = (from s in _pickables.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
				select s.Trim()).Distinct().ToArray();
		}
		EnableCritters = _enablecritters.Value;
		if (!_enablecritters.Value)
		{
			Array.Resize(ref Critters, 0);
		}
		else
		{
			Critters = (Critters = (from s in _critters.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
				select s.Trim()).Distinct().ToArray());
		}
		EnableOres = _enableores.Value;
		if (!_enableores.Value)
		{
			Array.Resize(ref Ores, 0);
		}
		else
		{
			Ores = (from s in _ores.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
				select s.Trim()).Distinct().ToArray();
		}
		if (_radius.Value > 150f)
		{
			_radius.Value = 150f;
		}
		Radius = _radius.Value;
		IconSize = _iconSize.Value;
		udrDebug = _udrdebug.Value;
		((BaseUnityPlugin)this).Logger.LogInfo((object)($"Enabled={Enabled} " + Environment.NewLine + $"PinText={PinText} " + Environment.NewLine + $"Debugging={udrDebug} " + Environment.NewLine + $"Radius={Radius} " + Environment.NewLine + $"IconSize={IconSize} " + Environment.NewLine + $"Pickables Enabled=({_enablepickables.Value})" + Environment.NewLine + "Pickables=(" + _pickables.Value + ")" + Environment.NewLine + $"Locations Enabled=({_enablelocations.Value})" + Environment.NewLine + "Locations=(" + _locations.Value + Environment.NewLine + $"Critters Enabled=({_enablecritters.Value})" + Environment.NewLine + "Critters=(" + _critters.Value + Environment.NewLine + $"Ores Enabled=({_enableores.Value})" + Environment.NewLine + "Ores=(" + _ores.Value));
		((BaseUnityPlugin)this).Config.Save();
		ObjectDB instance = ObjectDB.instance;
		if (Object.op_Implicit((Object)(object)instance))
		{
			UnderTheRadarUtils.LoadMasterLocIcons(Locations, udrDebug, instance);
			UnderTheRadarUtils.LoadMasterPickIcons(Pickables, udrDebug, instance);
			UnderTheRadarUtils.LoadMasterOreIcons(Ores, udrDebug, instance);
			UnderTheRadarUtils.LoadMasterCritterIcons(Critters, udrDebug, instance);
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Pickables Length = {Pickables.Length}");
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Locations Length = {Locations.Length}");
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Critters Length = {Critters.Length}");
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Ores Length = {Ores.Length}");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Under The Radar Settings Updated");
		}
	}

	private void ObjectDBAwakeHook(orig_Awake orig, ObjectDB self)
	{
		if (Enabled)
		{
			orig.Invoke(self);
			UnderTheRadarUtils.LoadMasterLocIcons(Locations, udrDebug, self);
			UnderTheRadarUtils.LoadMasterPickIcons(Pickables, udrDebug, self);
			UnderTheRadarUtils.LoadMasterOreIcons(Ores, udrDebug, self);
			UnderTheRadarUtils.LoadMasterCritterIcons(Critters, udrDebug, self);
		}
	}

	private void FishStartHook(orig_Start orig, Fish self)
	{
		if (!Enabled)
		{
			return;
		}
		orig.Invoke(self);
		bool flag = false;
		if (Critters.Length == 0)
		{
			return;
		}
		string[] critters = Critters;
		foreach (string text in critters)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			UnderTheRadarUtils.AddItemPinCritter(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
		}
	}

	private void BeehiveAwakeHook(orig_Awake orig, Beehive self)
	{
		if (!Enabled)
		{
			return;
		}
		orig.Invoke(self);
		bool flag = false;
		if (Critters.Length == 0)
		{
			return;
		}
		string[] critters = Critters;
		foreach (string text in critters)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			UnderTheRadarUtils.AddItemPinCritter(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
		}
	}

	private void CharacterAwakeHook(orig_Awake orig, Character self)
	{
		if (!Enabled)
		{
			return;
		}
		orig.Invoke(self);
		bool flag = false;
		if (Critters.Length == 0)
		{
			return;
		}
		string[] critters = Critters;
		foreach (string text in critters)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			UnderTheRadarUtils.AddItemPinCritter(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
		}
	}

	private void HumanoidAwakeHook(orig_Awake orig, Humanoid self)
	{
		if (!Enabled)
		{
			return;
		}
		orig.Invoke(self);
		bool flag = false;
		if (Critters.Length == 0)
		{
			return;
		}
		string[] critters = Critters;
		foreach (string text in critters)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			UnderTheRadarUtils.AddItemPinCritter(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
		}
	}

	private void LeviathanAwakeHook(orig_Awake orig, Leviathan self)
	{
		if (!Enabled)
		{
			return;
		}
		orig.Invoke(self);
		bool flag = false;
		if (Critters.Length == 0)
		{
			return;
		}
		string[] critters = Critters;
		foreach (string text in critters)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			UnderTheRadarUtils.AddItemPinCritter(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
		}
	}

	private void ResourceRootAwakeHook(orig_Awake orig, ResourceRoot self)
	{
		if (Enabled && Locations.Length != 0)
		{
			orig.Invoke(self);
			if (Array.Find(Locations, (string element) => element == "YggdrasilRoot") != null)
			{
				UnderTheRadarUtils.AddItemPinLocation(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
			}
		}
	}

	private void SapCollectorAwakeHook(orig_Awake orig, SapCollector self)
	{
		if (Enabled && Locations.Length != 0)
		{
			orig.Invoke(self);
			if (Array.Find(Locations, (string element) => element == "SapCollector") != null)
			{
				UnderTheRadarUtils.AddItemPinLocation(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
			}
		}
	}

	private void RoomAwakeHook(orig_Awake orig, Room self)
	{
		if (Enabled && Locations.Length != 0)
		{
			orig.Invoke(self);
			Vegvisir componentInChildren = ((Component)self).GetComponentInChildren<Vegvisir>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Debug.LogWarning((object)("Room Vege found = " + ((Object)componentInChildren).name));
				UnderTheRadarUtils.AddItemPinLocation(PinText, udrDebug, Radius, IconSize, ((Component)componentInChildren).gameObject);
			}
		}
	}

	private void LocationAwakeHook(orig_Awake orig, Location self)
	{
		bool flag = false;
		if (!Enabled || Locations.Length == 0)
		{
			return;
		}
		orig.Invoke(self);
		string[] locations = Locations;
		foreach (string text in locations)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (!flag)
		{
			return;
		}
		UnderTheRadarUtils.AddItemPinLocation(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
		Vegvisir componentInChildren = ((Component)self).GetComponentInChildren<Vegvisir>();
		if (!((Object)(object)componentInChildren != (Object)null))
		{
			return;
		}
		locations = Locations;
		foreach (string text2 in locations)
		{
			flag = ((Object)self).name.ToLower().Contains(text2.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			Debug.LogWarning((object)("Location Vege found = " + ((Object)componentInChildren).name));
			UnderTheRadarUtils.AddItemPinLocation(PinText, udrDebug, Radius, IconSize, ((Component)componentInChildren).gameObject);
		}
	}

	private void DestructibleAwakeHook(orig_Awake orig, Destructible self)
	{
		if (!Enabled)
		{
			return;
		}
		orig.Invoke(self);
		bool flag = false;
		if (Ores.Length == 0)
		{
			return;
		}
		if (((Object)self).name.ToLower().Contains("spawner") || ((Object)self).name.ToLower().Contains("altar_crystal") || ((Object)self).name.ToLower().Contains("mudpile"))
		{
			UnderTheRadarUtils.AddItemPinLocation(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
			return;
		}
		string[] ores = Ores;
		foreach (string text in ores)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			UnderTheRadarUtils.AddItemPinOre(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
		}
	}

	private void DropOnDestroyedAwakeHook(orig_Awake orig, DropOnDestroyed self)
	{
		if (Enabled)
		{
			orig.Invoke(self);
			if (UnderTheRadarUtils.WildSearch(((Object)self).name, "Beehive") == "Beehive" && Critters.Contains(((Object)self).name.Replace("(Clone)", "")))
			{
				UnderTheRadarUtils.AddItemPinCritter(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject);
			}
		}
	}

	private void PickableAwakeHook(orig_Awake orig, Pickable self)
	{
		if (!Enabled)
		{
			return;
		}
		orig.Invoke(self);
		if (Pickables.Length == 0)
		{
			return;
		}
		bool flag = false;
		string[] pickables = Pickables;
		foreach (string text in pickables)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			ItemDrop component = self.m_itemPrefab.GetComponent<ItemDrop>();
			if (!((Object)(object)component == (Object)null) && self.CanBePicked())
			{
				UnderTheRadarUtils.AddItemPinPickables(PinText, udrDebug, Radius, IconSize, ((Component)self).gameObject, component);
			}
		}
	}

	private void PickableSetPickedHook(orig_SetPicked orig, Pickable self, bool picked)
	{
		if (!Enabled)
		{
			return;
		}
		orig.Invoke(self, picked);
		if (!picked)
		{
			return;
		}
		bool flag = false;
		string[] pickables = Pickables;
		foreach (string text in pickables)
		{
			flag = ((Object)self).name.ToLower().Contains(text.ToLower());
			if (flag)
			{
				break;
			}
		}
		if (flag)
		{
			RadarPinComponent component = ((Component)self).gameObject.GetComponent<RadarPinComponent>();
			if (!((Object)(object)component == (Object)null))
			{
				Object.Destroy((Object)(object)component);
			}
		}
	}
}
internal class UnderTheRadarUtils : MonoBehaviour
{
	private static readonly IDictionary<string, Sprite> masterLocIcons = new Dictionary<string, Sprite>();

	private static readonly IDictionary<string, Sprite> locIcons = new Dictionary<string, Sprite>();

	private static readonly IDictionary<string, Sprite> masterPickIcons = new Dictionary<string, Sprite>();

	private static readonly IDictionary<string, Sprite> pickIcons = new Dictionary<string, Sprite>();

	private static readonly IDictionary<string, Sprite> masterOreIcons = new Dictionary<string, Sprite>();

	private static readonly IDictionary<string, Sprite> oreIcons = new Dictionary<string, Sprite>();

	private static readonly IDictionary<string, Sprite> masterCritterIcons = new Dictionary<string, Sprite>();

	private static readonly IDictionary<string, Sprite> critterIcons = new Dictionary<string, Sprite>();

	public static string WildSearch(string lookin, string lookfor)
	{
		Match match = new Regex(lookfor, RegexOptions.IgnoreCase).Match(lookin);
		if (match.Success)
		{
			return match.Value;
		}
		return "";
	}

	internal static void LoadMasterLocIcons(string[] Locations, bool udrDebug, ObjectDB objectDB)
	{
		masterLocIcons.Clear();
		foreach (string text in Locations)
		{
			string text2 = text;
			switch (text)
			{
			case "SunkenCrypt":
				text2 = "IronScrap";
				break;
			case "Crypt":
				text2 = "SurtlingCore";
				break;
			case "MountainCave":
				text2 = "Crystal";
				break;
			case "Vendor":
				text2 = "HelmetYule";
				break;
			case "MudPile":
				text2 = "IronScrap";
				break;
			case "TrollCave":
				text2 = "TrophyFrostTroll";
				break;
			case "Hut":
				text2 = "ShieldWoodTower";
				break;
			case "Cabin":
				text2 = "ShieldWoodTower";
				break;
			case "House":
				text2 = "ShieldWoodTower";
				break;
			case "Village":
				text2 = "ShieldIronBuckler";
				break;
			case "Tower":
				text2 = "ShieldBoneTower";
				break;
			case "Ruin":
				text2 = "ShieldBoneTower";
				break;
			case "Dolmen":
				text2 = "ShieldBlackmetalTower";
				break;
			case "Ship":
				text2 = "ShieldKnight";
				break;
			case "Grave":
				text2 = "ShieldBoneTower";
				break;
			case "Well":
				text2 = "ShieldBoneTower";
				break;
			case "FireHole":
				text2 = "FireworksRocket_Red";
				break;
			case "DrakeNest":
				text2 = "DragonEgg";
				break;
			case "TarPit":
				text2 = "Tar";
				break;
			case "Spawner":
				text2 = "StaminaUpgrade_Wraith";
				break;
			case "Camp":
				text2 = "TrophyGoblinBrute";
				break;
			case "Rune":
				text2 = "FlametalOre";
				break;
			case "Henge":
				text2 = "ShieldBlackmetal";
				break;
			case "Eikthyr":
				text2 = "TrophyEikthyr";
				break;
			case "GDKing":
				text2 = "TrophyTheElder";
				break;
			case "Bonemass":
				text2 = "TrophyBonemass";
				break;
			case "GoblinKing":
				text2 = "TrophyGoblinKing";
				break;
			case "DragonQueen":
				text2 = "TrophyDragonQueen";
				break;
			case "SeekerQueen":
				text2 = "TrophySeekerQueen";
				break;
			case "InfestedTree":
				text2 = "Guck";
				break;
			case "RoadPost":
				text2 = "ShieldCarapace";
				break;
			case "Excavation":
				text2 = "ShieldCarapaceBuckler";
				break;
			case "LightHouse":
				text2 = "ShieldBlackmetalTower";
				break;
			case "Fortress":
				text2 = "ShieldSerpentscale";
				break;
			case "DvergrTown":
				text2 = "ShieldSilver";
				break;
			case "DvergrBoss":
				text2 = "Lantern";
				break;
			case "altar_crystal":
				text2 = "DvergrKeyFragment";
				break;
			case "YggdrasilRoot":
				text2 = "Sap";
				break;
			case "SapCollector":
				text2 = "Acorn";
				break;
			case "Knarr":
				text2 = "Coins";
				break;
			}
			GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text2));
			if (!((Object)(object)itemPrefab != (Object)null))
			{
				continue;
			}
			Sprite val = itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons.FirstOrDefault();
			if ((Object)(object)val != (Object)null)
			{
				if (udrDebug)
				{
					string text3 = text.PadRight(15);
					Debug.LogWarning((object)("MLL Locations List Name = " + text3 + " Icon Used = " + ((Object)val).name + " "));
				}
				masterLocIcons.Add(text, val);
			}
		}
	}

	internal static void LoadMasterOreIcons(string[] Ores, bool udrDebug, ObjectDB objectDB)
	{
		masterOreIcons.Clear();
		foreach (string text in Ores)
		{
			string text2 = text;
			switch (text)
			{
			case "Copper":
				text2 = "CopperOre";
				break;
			case "Tin":
				text2 = "TinOre";
				break;
			case "Iron":
				text2 = "IronOre";
				break;
			case "Obsidian":
				text2 = "Obsidian";
				break;
			case "Silver":
				text2 = "SilverOre";
				break;
			case "Sword":
				text2 = "SwordIronFire";
				break;
			case "YggdrasilRoot":
				text2 = "Sap";
				break;
			case "Giant_Helmet":
				text2 = "HelmetMidsummerCrown";
				break;
			case "Giant_Ribs":
				text2 = "BoneFragments";
				break;
			case "Giant_Brain":
				text2 = "TrophySkeleton";
				break;
			case "Giant_Skull":
				text2 = "Softtissue";
				break;
			}
			GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text2));
			if (!((Object)(object)itemPrefab == (Object)null))
			{
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				if (!((Object)(object)component == (Object)null))
				{
					if (udrDebug)
					{
						string text3 = text.PadRight(15);
						Debug.LogWarning((object)("MOL Ore List Name = " + text3 + " Icon Used = " + text2 + " "));
					}
					masterOreIcons.Add(text, component.m_itemData.m_shared.m_icons.FirstOrDefault());
					continue;
				}
				break;
			}
			break;
		}
	}

	internal static void LoadMasterCritterIcons(string[] Critters, bool udrDebug, ObjectDB objectDB)
	{
		masterCritterIcons.Clear();
		foreach (string text in Critters)
		{
			string text2 = text;
			switch (text)
			{
			case "Serpent":
				text2 = "TrophySerpent";
				break;
			case "Leviathan":
				text2 = "Chitin";
				break;
			case "Fish":
				text2 = "FishRaw";
				break;
			case "Beehive":
				text2 = "QueenBee";
				break;
			case "Golem":
				text2 = "TrophySGolem";
				break;
			case "Troll":
				text2 = "TrollHide";
				break;
			case "Wraith":
				text2 = "TrophyWraith";
				break;
			case "Abomination":
				text2 = "HelmetRoot";
				break;
			case "Fenring":
				text2 = "TrophyFenring";
				break;
			case "Boar":
				text2 = "TrophyBoar";
				break;
			case "Deer":
				text2 = "TrophyDeer";
				break;
			case "Neck":
				text2 = "TrophyNeck";
				break;
			case "Wolf":
				text2 = "TrophyWolf";
				break;
			case "Hatchling":
				text2 = "TrophyHatchling";
				break;
			case "Deathsquito":
				text2 = "TrophyDeathsquito";
				break;
			case "Lox":
				text2 = "TrophyLox";
				break;
			case "BlobTar":
				text2 = "TrophyBlob";
				break;
			case "Blob":
				text2 = "TrophyBlob";
				break;
			case "BlobElite":
				text2 = "TrophyBlob";
				break;
			case "Leech":
				text2 = "TrophyLeech";
				break;
			case "Draugr":
				text2 = "TrophyDraugr";
				break;
			case "Surtling":
				text2 = "TrophySurtling";
				break;
			case "Chicken":
				text2 = "ChickenEgg";
				break;
			case "Hare":
				text2 = "TrophyHare";
				break;
			case "Gjall":
				text2 = "TrophyGjall";
				break;
			case "Seeker":
				text2 = "TrophySeekerBrute";
				break;
			case "Tick":
				text2 = "TrophyTick";
				break;
			case "Dverger":
				text2 = "StaffShield";
				break;
			case "Bat":
				text2 = "AncientSeed";
				break;
			}
			GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text2));
			if (!((Object)(object)itemPrefab == (Object)null))
			{
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				if (!((Object)(object)component == (Object)null))
				{
					if (udrDebug)
					{
						string text3 = text.PadRight(15);
						Debug.LogWarning((object)("MCL Critter List Name = " + text3 + " Icon Used = " + text2 + " "));
					}
					masterCritterIcons.Add(text, component.m_itemData.m_shared.m_icons.FirstOrDefault());
					continue;
				}
				break;
			}
			break;
		}
	}

	internal static void LoadMasterPickIcons(string[] Pickables, bool udrDebug, ObjectDB objectDB)
	{
		masterPickIcons.Clear();
		foreach (string text in Pickables)
		{
			string text2 = text;
			GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text2));
			if (!((Object)(object)itemPrefab == (Object)null))
			{
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				if (!((Object)(object)component == (Object)null))
				{
					if (udrDebug)
					{
						string text3 = text.PadRight(15);
						Debug.LogWarning((object)("MPL Pickable Name = " + text3 + " Icon Used = " + ((Object)component).name + " "));
					}
					masterPickIcons.Add(text, component.m_itemData.m_shared.m_icons.FirstOrDefault());
					continue;
				}
				break;
			}
			break;
		}
	}

	internal static void LoadPickIcons(bool udrDebug, string itemName, ItemDrop itemDrop)
	{
		if (!pickIcons.ContainsKey(itemName))
		{
			if (udrDebug)
			{
				string text = itemName.PadRight(15);
				Debug.LogWarning((object)("Load Pickable Icons - " + text + "  " + ((Object)itemDrop).name + " "));
			}
			pickIcons.Add(itemName, itemDrop.m_itemData.m_shared.m_icons.FirstOrDefault());
		}
	}

	internal static void LoadLocIcons(bool udrDebug, string itemName)
	{
		if (locIcons.ContainsKey(itemName))
		{
			return;
		}
		foreach (string key in masterLocIcons.Keys)
		{
			string text = WildSearch(itemName, key);
			string text2 = WildSearch(itemName, "SunkenCrypt");
			if (text != "" && (!(key == "Crypt") || !(text2 == "SunkenCrypt")))
			{
				if (udrDebug)
				{
					string text3 = itemName.PadRight(15);
					Debug.LogWarning((object)("Load New Location Icons - " + text3 + " " + key + " "));
				}
				locIcons.Add(itemName, masterLocIcons[key]);
				break;
			}
		}
	}

	internal static void LoadCritterIcons(bool udrDebug, string itemName)
	{
		if (critterIcons.ContainsKey(itemName))
		{
			return;
		}
		foreach (string key in masterCritterIcons.Keys)
		{
			if (!(WildSearch(itemName, key) != ""))
			{
				continue;
			}
			if (itemName.ToLower().Contains("fish"))
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemName.Replace("(Clone)", ""));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					break;
				}
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				if (!((Object)(object)component == (Object)null))
				{
					if (udrDebug)
					{
						string arg = itemName.PadRight(15);
						Debug.LogWarning((object)$"Load Critter Icons - {arg}  {component.m_itemData.m_shared.m_icons.FirstOrDefault()} ");
					}
					critterIcons.Add(itemName, component.m_itemData.m_shared.m_icons.FirstOrDefault());
				}
			}
			else
			{
				if (udrDebug)
				{
					string text = itemName.PadRight(15);
					Debug.LogWarning((object)("Load Critter Icons - " + text + "  " + key + " "));
				}
				critterIcons.Add(itemName, masterCritterIcons[key]);
			}
			break;
		}
	}

	internal static void LoadOreIcons(bool udrDebug, string itemName)
	{
		if (oreIcons.ContainsKey(itemName))
		{
			return;
		}
		foreach (string key in masterOreIcons.Keys)
		{
			if (WildSearch(itemName, key) != "")
			{
				if (udrDebug)
				{
					string text = itemName.PadRight(15);
					Debug.LogWarning((object)("Load Ore Icons - " + text + "  " + key + " "));
				}
				oreIcons.Add(itemName, masterOreIcons[key]);
				break;
			}
		}
	}

	internal static void AddItemPinPickables(bool pinText, bool udrDebug, float Radius, float IconSize, GameObject gameObject, ItemDrop itemDrop)
	{
		if (!((Object)(object)itemDrop == (Object)null))
		{
			string text = ((Object)itemDrop).name;
			if (text.Contains("Blueberry"))
			{
				text = "Blueberries";
			}
			if (text.Contains("Totem"))
			{
				text = "GoblinTotem";
			}
			if (text.Contains("Carrot"))
			{
				text = "Carrot";
			}
			if (text.Contains("Onion"))
			{
				text = "Onion";
			}
			if (text.Contains("Turnip"))
			{
				text = "Turnip";
			}
			if (true)
			{
				itemDrop = ObjectDB.instance.GetItemPrefab(text).GetComponent<ItemDrop>();
			}
			LoadPickIcons(udrDebug, text, itemDrop);
			if (pickIcons.ContainsKey(text))
			{
				gameObject.AddComponent<RadarPinComponent>().Create(pinText, text, Radius, IconSize, pickIcons[text]);
			}
		}
	}

	internal static void AddItemPinLocation(bool pinText, bool udrDebug, float Radius, float IconSize, GameObject gameObject)
	{
		string name = ((Object)gameObject).name;
		LoadLocIcons(udrDebug, name);
		if (locIcons.ContainsKey(name))
		{
			gameObject.AddComponent<RadarPinComponent>().Create(pinText, name, Radius, IconSize, locIcons[name]);
		}
	}

	internal static void AddItemPinCritter(bool pinText, bool udrDebug, float Radius, float IconSize, GameObject gameObject)
	{
		string name = ((Object)gameObject).name;
		LoadCritterIcons(udrDebug, name);
		if (critterIcons.ContainsKey(name))
		{
			gameObject.AddComponent<RadarPinComponent>().Create(pinText, name, Radius, IconSize, critterIcons[name]);
		}
	}

	internal static void AddItemPinOre(bool pinText, bool udrDebug, float Radius, float IconSize, GameObject gameObject)
	{
		string name = ((Object)gameObject).name;
		LoadOreIcons(udrDebug, name);
		if (oreIcons.ContainsKey(name))
		{
			gameObject.AddComponent<RadarPinComponent>().Create(pinText, name, Radius, IconSize, oreIcons[name]);
		}
	}

	internal static ItemDrop GetDroppedItem(IEnumerable<ItemDrop> drops)
	{
		return drops.Where((ItemDrop drop) => (int)drop.m_itemData.m_shared.m_itemType == 1).FirstOrDefault((Func<ItemDrop, bool>)((ItemDrop drop) => pickIcons.ContainsKey(drop.m_itemData.m_shared.m_name)));
	}
}