Decompiled source of Odins Wanted Posters v0.2.6

plugins/OdinsWantedPosters.dll

Decompiled 15 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("OdinsWantedPosters")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.6.0")]
[assembly: AssemblyInformationalVersion("0.2.6+409c40510ebf3e90cbfaf072c1c6144de2fef674")]
[assembly: AssemblyProduct("OdinsWantedPosters")]
[assembly: AssemblyTitle("OdinsWantedPosters")]
[assembly: AssemblyVersion("0.2.6.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OdinsWantedPosters
{
	internal static class FlavorText
	{
		private static readonly Dictionary<string, string> Lines = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
		{
			["Boar"] = "Bacon with opinions.",
			["Boar_piggy"] = "Tomorrow's bacon. Let it grow.",
			["Deer"] = "Fast, skittish, delicious.",
			["Hare"] = "All ears, all legs, no courage.",
			["Neck"] = "All neck, no manners.",
			["Chicken"] = "Lays eggs. Judges you.",
			["Hen"] = "Lays eggs. Judges you.",
			["Greyling"] = "Not a threat. Just rude.",
			["Eikthyr"] = "Antlers like lightning rods. Because they are.",
			["Greydwarf"] = "Throws rocks. Mostly at you.",
			["Greydwarf_Elite"] = "Smells of resin and bad decisions.",
			["Greydwarf_Shaman"] = "Heals his friends. Never you.",
			["Troll"] = "Odin has a thick file on this one.",
			["Skeleton"] = "Rattles. Bites. Holds grudges.",
			["Skeleton_Poison"] = "Smells worse than it fights. Barely.",
			["Ghost"] = "Boo, but meaner.",
			["Bjorn"] = "Big bear energy.",
			["gd_king"] = "The forest's oldest grudge.",
			["Draugr"] = "Died once already. Didn't take.",
			["Draugr_Elite"] = "Died once already. Came back angrier.",
			["Draugr_Ranged"] = "Died once already. Took up archery.",
			["BlobTar"] = "Tar with ambitions.",
			["Blob"] = "Do not lick.",
			["BlobElite"] = "Do not lick. Do not hug.",
			["Leech"] = "Wants a drink. Of you.",
			["Surtling"] = "Free fire. Mind your beard.",
			["Wraith"] = "Only comes out at night. For good reason.",
			["Abomination"] = "That's not a tree.",
			["Bonemass"] = "Bring a club and hold your breath.",
			["Wolf"] = "Good boy. Not your good boy.",
			["Wolf_cub"] = "Adorable. Its mother is not.",
			["Fenring_Cultist"] = "Wears a hood, throws fire. Bad combination.",
			["Hatchling"] = "Spits ice. Has no indoor voice.",
			["StoneGolem"] = "A mountain that learned to punch.",
			["Fenring"] = "Howls at the moon. Then at you.",
			["Ulv"] = "Never alone, never friendly.",
			["Bat"] = "Many. Always many.",
			["Dragon"] = "Moder. Mother of all bad days.",
			["Goblin"] = "Small, loud, well armed.",
			["GoblinArcher"] = "Small, loud, and now at range.",
			["Unbjorn"] = "A bear that got worse.",
			["Lox_Calf"] = "Small now. Give it a year.",
			["GoblinBrute"] = "The big one. There's always a big one.",
			["GoblinShaman"] = "Shields his friends, curses yours.",
			["Deathsquito"] = "Odin regrets this one.",
			["Lox"] = "Gentle giant. Until it isn't.",
			["GoblinKing"] = "Yagluth. Mostly torso, entirely angry.",
			["Serpent"] = "Why the boat feels small.",
			["Seeker"] = "Too many legs, too many eyes.",
			["SeekerBrute"] = "A seeker that skipped no meals.",
			["SeekerBrood"] = "Seeker, small size. Same attitude.",
			["DvergerMage"] = "Small, bearded, and casting at you.",
			["DvergerMageFire"] = "Small, bearded, and casting at you.",
			["DvergerMageIce"] = "Small, bearded, and casting at you.",
			["DvergerMageSupport"] = "Small, bearded, and casting at you.",
			["Tick"] = "Small. Thirsty. Persistent.",
			["Gjall"] = "Floats. Drops ticks. Ruins days.",
			["Dverger"] = "Leave them be and they'll leave you be.",
			["SeekerQueen"] = "The hive's mother. Not the cuddly kind.",
			["Charred_Melee"] = "Burned once. Still swinging.",
			["Charred_Archer"] = "Burned once. Still aiming.",
			["Charred_Mage"] = "Burned once. Took up magic.",
			["Charred_Twitcher"] = "Twitchy. Very twitchy.",
			["Asksvin_hatchling"] = "A lizard with a schedule, junior edition.",
			["BonemawSerpent"] = "The serpent, but from somewhere worse.",
			["Morgen"] = "Sleeps a lot. Wakes up worse.",
			["Asksvin"] = "A lizard with a schedule to keep.",
			["Volture"] = "Circles the dying. Don't be the dying.",
			["FallenValkyrie"] = "Odin knows her. It's complicated.",
			["Fader"] = "The last tab Odin can't cover.",
			["Skeleton_Hildir"] = "Hildir wants her chest back. So does this one.",
			["Fenring_Cultist_Hildir"] = "Hildir wants her chest back. So does this one.",
			["GoblinBrute_Hildir"] = "Hildir wants her chest back. So do these two.",
			["GoblinShaman_Hildir"] = "Hildir wants her chest back. So do these two.",
			["GoblinShaman_Staff_Hildir"] = "Hildir wants her chest back. So do these two."
		};

		internal static string For(Character c)
		{
			string text = Utils.GetPrefabName(((Component)c).gameObject);
			while (true)
			{
				if (Lines.TryGetValue(text, out var value))
				{
					return value;
				}
				int num = text.LastIndexOf('_');
				if (num <= 0)
				{
					break;
				}
				text = text.Substring(0, num);
			}
			if (!c.IsBoss())
			{
				return "Odin's ravens are still taking notes.";
			}
			return "Odin's file on this one is very thick.";
		}
	}
	internal enum TriggerMode
	{
		LookAndPress,
		Look
	}
	internal enum PlacementMode
	{
		Crosshair,
		AboveCreature,
		Pinned
	}
	[BepInPlugin("hevyh2o.valheim.odinswantedposters", "Odin's Wanted Posters", "0.2.6")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "hevyh2o.valheim.odinswantedposters";

		public const string Name = "Odin's Wanted Posters";

		public const string Version = "0.2.6";

		internal static ConfigEntry<TriggerMode> Trigger;

		internal static ConfigEntry<KeyboardShortcut> ShowKey;

		internal static ConfigEntry<float> ShowSeconds;

		internal static ConfigEntry<PlacementMode> Placement;

		internal static ConfigEntry<float> PinnedX;

		internal static ConfigEntry<float> PinnedY;

		internal static ConfigEntry<float> MaxDistance;

		internal static ConfigEntry<bool> ShowHealth;

		internal static ConfigEntry<bool> ShowWeaknesses;

		internal static ConfigEntry<bool> ShowDrops;

		internal static ConfigEntry<bool> ShowDropChances;

		internal static ConfigEntry<bool> UnseenDropsHidden;

		internal static ConfigEntry<bool> ShowTames;

		internal static ConfigEntry<bool> ShowFlavor;

		private PosterTooltip _tooltip;

		private void Awake()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			Trigger = ((BaseUnityPlugin)this).Config.Bind<TriggerMode>("Display", "Trigger", TriggerMode.LookAndPress, "LookAndPress: look at a creature and press ShowKey to see its poster for ShowSeconds. Look: the poster shows whenever you look at a creature.");
			ShowKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Display", "ShowKey", new KeyboardShortcut((KeyCode)101, Array.Empty<KeyCode>()), "Key that brings up the poster in LookAndPress mode. Shares E with Use by default, which is harmless: creatures you can't use just get a poster.");
			ShowSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ShowSeconds", 5f, new ConfigDescription("How long the poster stays up after pressing ShowKey. Press again to restart the timer.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
			Placement = ((BaseUnityPlugin)this).Config.Bind<PlacementMode>("Display", "Placement", PlacementMode.Crosshair, "Crosshair: beside the crosshair. AboveCreature: floating over the creature's head. Pinned: a fixed spot you choose by dragging the poster while your inventory is open.");
			PinnedX = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "PinnedX", 0.8f, new ConfigDescription("Pinned poster's horizontal position, 0 = left edge, 1 = right edge. Set by dragging it while the inventory is open.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PinnedY = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "PinnedY", 0.6f, new ConfigDescription("Pinned poster's vertical position, 0 = bottom, 1 = top. Set by dragging it while the inventory is open.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxDistance", 30f, new ConfigDescription("How far away (in metres) a creature can be and still get a poster.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 50f), Array.Empty<object>()));
			ShowHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowHealth", true, "Show the creature's current and maximum health.");
			ShowWeaknesses = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowWeaknesses", true, "Show what the creature is weak to, resists and is immune to.");
			ShowDrops = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowDrops", true, "Show what the creature can drop.");
			ShowDropChances = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowDropChances", true, "Show the chance of each drop, adjusted for the creature's stars.");
			UnseenDropsHidden = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UnseenDropsHidden", false, "Show drops as ??? until you've picked that item up at least once. For players who'd rather find out the hard way.");
			ShowTames = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowTames", false, "Show posters for tamed animals too.");
			ShowFlavor = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowFlavor", true, "Show Odin's one-line remark under the creature's name.");
			_tooltip = ((Component)this).gameObject.AddComponent<PosterTooltip>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Odin's Wanted Posters 0.2.6 loaded. The ravens are watching.");
		}

		private void OnDestroy()
		{
			if ((Object)(object)_tooltip != (Object)null)
			{
				Object.Destroy((Object)(object)_tooltip);
			}
		}
	}
	internal class PosterTooltip : MonoBehaviour
	{
		private const float RefreshInterval = 0.1f;

		private static readonly Vector2 CrosshairOffset = new Vector2(60f, 40f);

		private const float AboveCreatureGap = 12f;

		private GameObject _tooltip;

		private RectTransform _panel;

		private Graphic _panelGraphic;

		private TMP_Text _topic;

		private TMP_Text _text;

		private Canvas _canvas;

		private readonly Vector3[] _corners = (Vector3[])(object)new Vector3[4];

		private Character _shown;

		private float _nextRefresh;

		private Character _locked;

		private float _lockedUntil;

		private bool _dragging;

		private Vector2 _dragOffset;

		private Vector2 _dragFraction;

		private const string PlaceholderTitle = "Odin's Wanted Posters";

		private const string PlaceholderBody = "Drag this poster where you want it.\nIt stays there when you close your inventory.";

		private void LateUpdate()
		{
			bool flag = Plugin.Placement.Value == PlacementMode.Pinned && InPinEditMode();
			Character val = (flag ? EditModeTarget() : FindTarget());
			if ((Object)(object)val == (Object)null && !flag)
			{
				Hide();
			}
			else
			{
				if ((Object)(object)_tooltip == (Object)null && !CreateTooltip())
				{
					return;
				}
				if ((Object)(object)val != (Object)(object)_shown || Time.time >= _nextRefresh)
				{
					_shown = val;
					_nextRefresh = Time.time + 0.1f;
					if ((Object)(object)val != (Object)null)
					{
						_topic.text = WantedPoster.Title(val);
						_text.text = WantedPoster.Body(val);
					}
					else
					{
						_topic.text = "Odin's Wanted Posters";
						_text.text = "Drag this poster where you want it.\nIt stays there when you close your inventory.";
					}
					LayoutRebuilder.ForceRebuildLayoutImmediate(_panel);
				}
				if (!_tooltip.activeSelf)
				{
					_tooltip.SetActive(true);
					_tooltip.transform.SetAsLastSibling();
				}
				if ((Object)(object)_panelGraphic != (Object)null)
				{
					_panelGraphic.raycastTarget = flag;
				}
				if (!Place(val, flag))
				{
					_tooltip.SetActive(false);
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_tooltip != (Object)null)
			{
				Object.Destroy((Object)(object)_tooltip);
			}
		}

		private Character FindTarget()
		{
			Character val = (CanShow() ? LookTarget() : null);
			if (Plugin.Trigger.Value == TriggerMode.Look)
			{
				return val;
			}
			if ((Object)(object)val != (Object)null && ShowKeyDown())
			{
				_locked = val;
				_lockedUntil = Time.time + Plugin.ShowSeconds.Value;
			}
			if ((Object)(object)_locked != (Object)null && (Time.time > _lockedUntil || !IsValid(_locked)))
			{
				_locked = null;
			}
			if (!CanShow())
			{
				return null;
			}
			return _locked;
		}

		private Character EditModeTarget()
		{
			if (!IsValid(_shown))
			{
				return null;
			}
			return _shown;
		}

		private static Character LookTarget()
		{
			Character hoverCreature = Player.m_localPlayer.GetHoverCreature();
			if (!IsValid(hoverCreature))
			{
				return null;
			}
			return hoverCreature;
		}

		private static bool IsValid(Character c)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)c == (Object)null || (Object)(object)localPlayer == (Object)null || c.IsPlayer() || c.IsDead())
			{
				return false;
			}
			if (c.IsTamed() && !Plugin.ShowTames.Value)
			{
				return false;
			}
			float value = Plugin.MaxDistance.Value;
			Vector3 val = ((Component)c).transform.position - ((Component)localPlayer).transform.position;
			return ((Vector3)(ref val)).sqrMagnitude <= value * value;
		}

		private static bool CanShow()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || !HudVisible())
			{
				return false;
			}
			if (!InventoryGui.IsVisible() && !Menu.IsVisible() && !Minimap.IsOpen() && !TextInput.IsVisible() && !Console.IsVisible())
			{
				if ((Object)(object)Chat.instance != (Object)null)
				{
					return !Chat.instance.HasFocus();
				}
				return true;
			}
			return false;
		}

		private static bool InPinEditMode()
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null && HudVisible() && InventoryGui.IsVisible())
			{
				return !Menu.IsVisible();
			}
			return false;
		}

		private static bool HudVisible()
		{
			if ((Object)(object)Hud.instance != (Object)null && !Hud.IsUserHidden())
			{
				return Hud.instance.IsVisible();
			}
			return false;
		}

		private static bool ShowKeyDown()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = Plugin.ShowKey.Value;
			if ((int)((KeyboardShortcut)(ref value)).MainKey == 0 || !ZInput.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey, false))
			{
				return false;
			}
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref value)).Modifiers)
			{
				if (!ZInput.GetKey(modifier, false))
				{
					return false;
				}
			}
			return true;
		}

		private bool Place(Character target, bool editing)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			float scaleFactor = _canvas.scaleFactor;
			switch (Plugin.Placement.Value)
			{
			case PlacementMode.AboveCreature:
			{
				Camera mainCamera = Utils.GetMainCamera();
				if ((Object)(object)mainCamera == (Object)null || (Object)(object)target == (Object)null)
				{
					return false;
				}
				Vector3 val2 = mainCamera.WorldToScreenPoint(target.GetTopPoint());
				if (val2.z <= 0f)
				{
					return false;
				}
				PlacePanel(new Vector2(val2.x, val2.y + 12f * scaleFactor), new Vector2(0.5f, 0f));
				return true;
			}
			case PlacementMode.Pinned:
			{
				if (editing)
				{
					HandleDrag();
				}
				else
				{
					_dragging = false;
				}
				Vector2 screenPoint = Vector2.Scale(PinnedFraction(), new Vector2((float)Screen.width, (float)Screen.height));
				PlacePanel(screenPoint, new Vector2(0.5f, 0.5f));
				return true;
			}
			default:
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)Screen.width / 2f, (float)Screen.height / 2f);
				_tooltip.transform.position = Vector2.op_Implicit(val + CrosshairOffset * scaleFactor);
				Utils.ClampUIToScreen(_panel);
				return true;
			}
			}
		}

		private void PlacePanel(Vector2 screenPoint, Vector2 pivot)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			_tooltip.transform.position = Vector2.op_Implicit(screenPoint);
			_panel.GetWorldCorners(_corners);
			Vector2 val = Vector2.op_Implicit(_corners[0]);
			Vector2 val2 = Vector2.op_Implicit(_corners[2]);
			Vector2 val3 = val + Vector2.Scale(val2 - val, pivot);
			Transform transform = _tooltip.transform;
			transform.position += Vector2.op_Implicit(screenPoint - val3);
			Utils.ClampUIToScreen(_panel);
		}

		private Vector2 PinnedFraction()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!_dragging)
			{
				return new Vector2(Plugin.PinnedX.Value, Plugin.PinnedY.Value);
			}
			return _dragFraction;
		}

		private void HandleDrag()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = Vector2.op_Implicit(ZInput.pointerPosition);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor((float)Screen.width, (float)Screen.height);
			if (!_dragging && ZInput.GetMouseButtonDown(0) && RectTransformUtility.RectangleContainsScreenPoint(_panel, val, (Camera)null))
			{
				_dragging = true;
				_dragFraction = new Vector2(Plugin.PinnedX.Value, Plugin.PinnedY.Value);
				_dragOffset = Vector2.Scale(_dragFraction, val2) - val;
			}
			if (_dragging)
			{
				Vector2 val3 = val + _dragOffset;
				_dragFraction = new Vector2(Mathf.Clamp01(val3.x / val2.x), Mathf.Clamp01(val3.y / val2.y));
				if (!ZInput.GetMouseButton(0))
				{
					_dragging = false;
					Plugin.PinnedX.Value = _dragFraction.x;
					Plugin.PinnedY.Value = _dragFraction.y;
				}
			}
		}

		private bool CreateTooltip()
		{
			GameObject val = FindTooltipPrefab();
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Canvas componentInParent = ((Component)InventoryGui.instance).GetComponentInParent<Canvas>();
			_canvas = ((componentInParent != null) ? componentInParent.rootCanvas : null);
			if ((Object)(object)_canvas == (Object)null)
			{
				return false;
			}
			_tooltip = Object.Instantiate<GameObject>(val, ((Component)_canvas).transform);
			((Object)_tooltip).name = "OdinsWantedPoster";
			ref RectTransform panel = ref _panel;
			Transform child = _tooltip.transform.GetChild(0);
			panel = (RectTransform)(object)((child is RectTransform) ? child : null);
			Transform obj = Utils.FindChild(_tooltip.transform, "Topic", (IterativeSearchType)0);
			_topic = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
			Transform obj2 = Utils.FindChild(_tooltip.transform, "Text", (IterativeSearchType)0);
			_text = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null);
			if ((Object)(object)_panel == (Object)null || (Object)(object)_topic == (Object)null || (Object)(object)_text == (Object)null)
			{
				Object.Destroy((Object)(object)_tooltip);
				_tooltip = null;
				return false;
			}
			Graphic[] componentsInChildren = _tooltip.GetComponentsInChildren<Graphic>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].raycastTarget = false;
			}
			_panelGraphic = ((Component)_panel).GetComponent<Graphic>();
			return true;
		}

		private static GameObject FindTooltipPrefab()
		{
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			UITooltip val = (((Object)(object)instance.m_playerGrid != (Object)null && (Object)(object)instance.m_playerGrid.m_elementPrefab != (Object)null) ? instance.m_playerGrid.m_elementPrefab.GetComponentInChildren<UITooltip>(true) : null);
			if ((Object)(object)val != (Object)null && (Object)(object)val.m_tooltipPrefab != (Object)null)
			{
				return val.m_tooltipPrefab;
			}
			UITooltip[] componentsInChildren = ((Component)instance).GetComponentsInChildren<UITooltip>(true);
			foreach (UITooltip val2 in componentsInChildren)
			{
				if ((Object)(object)val2.m_tooltipPrefab != (Object)null)
				{
					return val2.m_tooltipPrefab;
				}
			}
			return null;
		}

		private void Hide()
		{
			_shown = null;
			_dragging = false;
			if ((Object)(object)_tooltip != (Object)null && _tooltip.activeSelf)
			{
				_tooltip.SetActive(false);
			}
		}
	}
	internal static class WantedPoster
	{
		private const string Value = "orange";

		private const string WeakColor = "#FF7A5C";

		private const string ResistColor = "#9FD0FF";

		private const string ImmuneColor = "#B0B0B0";

		private const string FlavorColor = "#B9B3A8";

		private static readonly StringBuilder Sb = new StringBuilder();

		private static readonly List<string> Weak = new List<string>();

		private static readonly List<string> Resist = new List<string>();

		private static readonly List<string> Immune = new List<string>();

		internal static string Title(Character c)
		{
			return Localize(c.m_name);
		}

		internal static string Body(Character c)
		{
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			Sb.Clear();
			if (Plugin.ShowFlavor.Value)
			{
				Sb.Append("<i><color=").Append("#B9B3A8").Append('>')
					.Append(FlavorText.For(c))
					.Append("</color></i>\n\n");
			}
			int level = c.GetLevel();
			Sb.Append("Level: <color=").Append("orange").Append('>')
				.Append(level);
			if (level > 1)
			{
				Sb.Append((level == 2) ? " (1 star)" : $" ({level - 1} stars)");
			}
			Sb.Append("</color>\n");
			if (Plugin.ShowHealth.Value)
			{
				Sb.Append("Health: <color=").Append("orange").Append('>')
					.Append(Mathf.CeilToInt(c.GetHealth()))
					.Append(" / ")
					.Append(Mathf.CeilToInt(c.GetMaxHealth()))
					.Append("</color>\n");
			}
			if (Plugin.ShowWeaknesses.Value)
			{
				AppendDamageModifiers(c.GetDamageModifiers((WeakSpot)null));
			}
			if (Plugin.ShowDrops.Value)
			{
				AppendDrops(c);
			}
			return Sb.ToString().TrimEnd(new char[1] { '\n' });
		}

		private static void AppendDamageModifiers(DamageModifiers mods)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			Weak.Clear();
			Resist.Clear();
			Immune.Clear();
			Sort("Blunt", mods.m_blunt);
			Sort("Slash", mods.m_slash);
			Sort("Pierce", mods.m_pierce);
			Sort("Fire", mods.m_fire);
			Sort("Frost", mods.m_frost);
			Sort("Lightning", mods.m_lightning);
			Sort("Poison", mods.m_poison);
			Sort("Spirit", mods.m_spirit);
			if (Weak.Count + Resist.Count + Immune.Count != 0)
			{
				Sb.Append('\n');
				AppendList("Weak to", Weak, "#FF7A5C");
				AppendList("Resists", Resist, "#9FD0FF");
				AppendList("Immune to", Immune, "#B0B0B0");
			}
		}

		private static void Sort(string type, DamageModifier mod)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected I4, but got Unknown
			switch (mod - 1)
			{
			case 5:
				Weak.Add(type + " (very)");
				break;
			case 1:
				Weak.Add(type);
				break;
			case 7:
				Weak.Add(type + " (slightly)");
				break;
			case 4:
				Resist.Add(type + " (very)");
				break;
			case 0:
				Resist.Add(type);
				break;
			case 6:
				Resist.Add(type + " (slightly)");
				break;
			case 2:
			case 3:
				Immune.Add(type);
				break;
			}
		}

		private static void AppendList(string label, List<string> items, string color)
		{
			if (items.Count != 0)
			{
				Sb.Append(label).Append(": <color=").Append(color)
					.Append('>')
					.Append(string.Join(", ", items))
					.Append("</color>\n");
			}
		}

		private static void AppendDrops(Character c)
		{
			CharacterDrop component = ((Component)c).GetComponent<CharacterDrop>();
			if ((Object)(object)component == (Object)null || component.m_drops.Count == 0)
			{
				return;
			}
			int num = Mathf.Max(1, (int)Mathf.Pow(2f, (float)(c.GetLevel() - 1)));
			Player localPlayer = Player.m_localPlayer;
			bool flag = false;
			foreach (Drop drop in component.m_drops)
			{
				if ((Object)(object)drop.m_prefab == (Object)null || drop.m_chance <= 0f)
				{
					continue;
				}
				ItemDrop component2 = drop.m_prefab.GetComponent<ItemDrop>();
				if (!((Object)(object)component2 == (Object)null))
				{
					if (!flag)
					{
						Sb.Append("\nDrops:\n");
						flag = true;
					}
					string name = component2.m_itemData.m_shared.m_name;
					bool flag2 = !Plugin.UnseenDropsHidden.Value || ((Object)(object)localPlayer != (Object)null && localPlayer.IsMaterialKnown(name));
					Sb.Append("  ").Append(flag2 ? Localize(name) : "???");
					if (Plugin.ShowDropChances.Value)
					{
						float chance = Mathf.Min(1f, drop.m_levelMultiplier ? (drop.m_chance * (float)num) : drop.m_chance);
						Sb.Append(" <color=").Append("orange").Append('>')
							.Append(FormatChance(chance))
							.Append("</color>");
					}
					Sb.Append('\n');
				}
			}
		}

		private static string FormatChance(float chance)
		{
			float num = chance * 100f;
			if (!(num >= 10f) && !Mathf.Approximately(num, Mathf.Round(num)))
			{
				return $"{num:0.#}%";
			}
			return $"{Mathf.RoundToInt(num)}%";
		}

		private static string Localize(string token)
		{
			if (Localization.instance == null)
			{
				return token;
			}
			return Localization.instance.Localize(token);
		}
	}
	internal static class BuildInfo
	{
		public const string Version = "0.2.6";
	}
}