Decompiled source of RagnarokRPG v0.8.5

plugins/RagnarokJobs.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using RagnarokJobs.Commands;
using RagnarokJobs.Creatures;
using RagnarokJobs.Dev;
using RagnarokJobs.Integration;
using RagnarokJobs.Items;
using RagnarokJobs.Jobs;
using RagnarokJobs.Music;
using RagnarokJobs.Patches;
using RagnarokJobs.SkillSystem;
using RagnarokJobs.Ui;
using SeneaL.API;
using SoftReferenceableAssets;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[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 RagnarokJobs
{
	public static class ModConfig
	{
		public static ConfigEntry<KeyboardShortcut> SkillWindowKey;

		public static ConfigEntry<KeyboardShortcut> StatusWindowKey;

		public static ConfigEntry<KeyboardShortcut> SkillStackKey;

		public static ConfigEntry<KeyboardShortcut> ItemBarKey;

		public static ConfigEntry<int> SkillStacks;

		public static ConfigEntry<bool> ShowKeyHints;

		public static ConfigEntry<string> RoClientFolder;

		public static ConfigEntry<bool> PreferRoTextures;

		public static ConfigEntry<bool> UseModMusic;

		public static ConfigEntry<bool> RoDamageNumbers;

		public static ConfigEntry<bool> GamepadControls;

		public static ConfigEntry<bool> MobScaling;

		public static ConfigEntry<float> JobExpRate;

		public static ConfigEntry<float> PoringDensity;

		public static void Bind(ConfigFile config)
		{
			//IL_001b: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Expected O, but got Unknown
			SkillWindowKey = config.Bind<KeyboardShortcut>("Keys", "SkillWindow", new KeyboardShortcut((KeyCode)107, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Open or close the job / skill window");
			StatusWindowKey = config.Bind<KeyboardShortcut>("Keys", "StatusWindow", new KeyboardShortcut((KeyCode)97, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Open or close the status window (RO's Alt+A)");
			SkillStackKey = config.Bind<KeyboardShortcut>("Keys", "SkillStack", new KeyboardShortcut((KeyCode)115, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Switch keys 1-8 to skills; press again for the next skill stack");
			ItemBarKey = config.Bind<KeyboardShortcut>("Keys", "ItemBar", new KeyboardShortcut((KeyCode)101, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Switch keys 1-8 back to the item hotbar");
			SkillStacks = config.Bind<int>("SkillBar", "Stacks", 4, new ConfigDescription("Number of skill stacks (8 slots each)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			RoClientFolder = config.Bind<string>("Sounds", "RoClientFolder", "", "Optional: folder of your own Ragnarok Online client (with data.grf). If set, skills play RO's sounds read from it at runtime instead of the mod's own. Nothing from RO ships with this mod.");
			PreferRoTextures = config.Bind<bool>("Textures", "PreferRoTextures", false, "Use RO's own effect textures from your RO client (RoClientFolder) instead of the mod's. Off: the mod's own textures, drawn in Valheim's style after RO's.");
			UseModMusic = config.Bind<bool>("Music", "UseModMusic", true, "Play the mod's own background music in the biomes it has music for (Meadows, Black Forest, Plains, Ashlands), fading out, pausing a few seconds and picking a random track on each biome change. Raids, dungeons, boss areas and sailing keep Valheim's music, as do biomes without ours. Off: Valheim's music everywhere.");
			RoDamageNumbers = config.Bind<bool>("Display", "RoDamageNumbers", true, "RO-style damage numbers: big outlined pixel digits that pop out of the target and arc away as they shrink. White for your hits, yellow and bigger on a weakness, grey and smaller when resisted, dark grey when immune, red for hits on you, gold on a red burst for criticals (staggered or sneak-attacked creatures), green heals, and \"Miss\". Off: Valheim's damage text.");
			ShowKeyHints = config.Bind<bool>("SkillBar", "ShowKeyHints", true, "Show a short key hint under the item hotbar and the skill bar");
			GamepadControls = config.Bind<bool>("Gamepad", "Enabled", true, "Controller skill controls (Valheim's default controller layout): LT + Y/X/B/A cast, LT + RB dodges (instead of LT + B), LT + D-pad down/up change skill page, LB + D-pad up/down zoom the camera, LB + Y / LB + X open the skill / status window. Off: the controller works as in vanilla.");
			ConfigurationManagerAttributes val = new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			};
			MobScaling = config.Bind<bool>("Server", "MobScaling", true, new ConfigDescription("Use the mod's creature scaling: once Eikthyr is defeated, creatures have 1.3x health (1.7x from the Plains on) and deal 1.3x damage, to match the jobs' power. Also twice as many Skeletons in the Black Forest at night, and some by day too (as many as Valheim has at night). Off: vanilla creatures. Health and spawn changes apply to creatures that spawn afterwards.", (AcceptableValueBase)null, new object[1] { val }));
			JobExpRate = config.Bind<float>("Server", "JobExpRate", 1f, new ConfigDescription("Multiplier on the job exp from kills (2 = twice as fast).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), new object[1] { val }));
			PoringDensity = config.Bind<float>("Server", "PoringDensity", 5f, new ConfigDescription("How many Porings live in the Meadows, compared with Boars (5 = five times as many, spawning five times as often). 0: no Porings. Applies to new spawns.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), new object[1] { val }));
		}

		public static string Label(KeyboardShortcut shortcut)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers)
			{
				list.Add(KeyName(modifier));
			}
			list.Add(KeyName(((KeyboardShortcut)(ref shortcut)).MainKey));
			return string.Join("+", list);
		}

		private unsafe static string KeyName(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected I4, but got Unknown
			switch (key - 303)
			{
			case 4:
			case 5:
				return "Alt";
			case 2:
			case 3:
				return "Ctrl";
			case 0:
			case 1:
				return "Shift";
			default:
				return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString();
			}
		}
	}
	public static class PadInput
	{
		private static int _frame = -1;

		private static bool _lt;

		private static bool _lb;

		private static bool _raw;

		public static bool Active
		{
			get
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Invalid comparison between Unknown and I4
				if (ModConfig.GamepadControls.Value && ZInput.IsGamepadActive())
				{
					return (int)ZInput.InputLayout == 0;
				}
				return false;
			}
		}

		public static bool CastLayer
		{
			get
			{
				Poll();
				return _lt;
			}
		}

		public static bool PageLayer
		{
			get
			{
				Poll();
				if (_lb)
				{
					return !_lt;
				}
				return false;
			}
		}

		private static void Poll()
		{
			if (_frame == Time.frameCount)
			{
				return;
			}
			int num;
			int lt;
			if (Active)
			{
				num = (InPlay() ? 1 : 0);
				if (num != 0)
				{
					lt = (ZInput.GetButton("JoyLTrigger") ? 1 : 0);
					goto IL_002c;
				}
			}
			else
			{
				num = 0;
			}
			lt = 0;
			goto IL_002c;
			IL_002c:
			_lt = (byte)lt != 0;
			_lb = num != 0 && ZInput.GetButton("JoyLBumper");
			_frame = Time.frameCount;
		}

		private static bool InPlay()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null && ((Character)localPlayer).TakeInput() && !((Character)localPlayer).InPlaceMode() && !Hud.InRadial())
			{
				return !Windows.AnyOpen;
			}
			return false;
		}

		public static int FacePressed()
		{
			if (Down("JoyButtonY"))
			{
				return 0;
			}
			if (Down("JoyButtonX"))
			{
				return 1;
			}
			if (Down("JoyButtonB"))
			{
				return 2;
			}
			if (Down("JoyButtonA"))
			{
				return 3;
			}
			return -1;
		}

		public static bool Down(string name)
		{
			return Raw(name, down: true);
		}

		public static bool Held(string name)
		{
			return Raw(name, down: false);
		}

		private static bool Raw(string name, bool down)
		{
			_raw = true;
			try
			{
				return down ? ZInput.GetButtonDown(name) : ZInput.GetButton(name);
			}
			finally
			{
				_raw = false;
			}
		}

		public static bool Muted(string name)
		{
			if (_raw)
			{
				return false;
			}
			switch (name)
			{
			case "JoyButtonA":
			case "JoyButtonB":
			case "JoyUse":
			case "JoyJump":
			case "JoyDodge":
			case "JoySecondaryAttack":
				return CastLayer;
			case "JoyButtonX":
			case "JoyButtonY":
			case "JoySit":
			case "JoyInventory":
				if (!CastLayer)
				{
					return PageLayer;
				}
				return true;
			case "JoyDPadUp":
			case "JoyDPadDown":
				if (!CastLayer)
				{
					return PageLayer;
				}
				return true;
			case "JoyCamZoomIn":
			case "JoyCamZoomOut":
				return CastLayer;
			case "JoyHotbarUse":
			case "JoyGP":
				if (!CastLayer)
				{
					return PageLayer;
				}
				return true;
			default:
				return false;
			}
		}
	}
	public static class Windows
	{
		public static bool AnyOpen
		{
			get
			{
				if (!SkillWindow.IsOpen && !StatusWindow.IsOpen && !JobAltarWindow.IsOpen && !WarpPortalWindow.IsOpen)
				{
					return FallenWindow.IsOpen;
				}
				return true;
			}
		}
	}
	[HarmonyPatch(typeof(ZInput), "TryGetButtonState")]
	public static class PadMutePatch
	{
		private static bool Prefix(string name, ref bool __result)
		{
			if (!PadInput.Muted(name))
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
	public static class PadZoomPatch
	{
		private static void Prefix(GameCamera __instance, float dt)
		{
			if (PadInput.PageLayer)
			{
				if (PadInput.Held("JoyDPadUp"))
				{
					__instance.m_distance -= __instance.m_zoomSens * dt;
				}
				else if (PadInput.Held("JoyDPadDown"))
				{
					__instance.m_distance += __instance.m_zoomSens * dt;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetControls")]
	public static class PadDodgePatch
	{
		private static void Prefix(Player __instance, ref bool jump)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && PadInput.CastLayer && PadInput.Down("JoyRBumper"))
			{
				jump = true;
			}
		}
	}
	[BepInPlugin("ragnarokjobs.valheim", "Ragnarok RPG", "0.8.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGuid = "ragnarokjobs.valheim";

		public const string ModName = "Ragnarok RPG";

		public const string ModVersion = "0.8.5";

		public const string SeneaLApiGuid = "seneaL.valheim.api";

		public const string SeneaLUiGuid = "seneaL.valheim.ui";

		internal static ManualLogSource Log;

		private readonly Harmony _harmony = new Harmony("ragnarokjobs.valheim");

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			ModConfig.Bind(((BaseUnityPlugin)this).Config);
			CommandRegistry.Add((ConsoleCommand)(object)new DumpAttacksCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new DumpCreaturesCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new DumpPrefabsCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new JobStatusCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new SetJobCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new SpawnAltarCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new AddJobExpCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new SetJobLevelCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new DummyCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new DummyLiveCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new DummyRefreshCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new DummySpawnCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new SkillsListCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new LearnCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new ResetSkillsCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new CastCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new NoCooldownCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new MaxStatCommand(eitr: false));
			CommandRegistry.Add((ConsoleCommand)(object)new MaxStatCommand(eitr: true));
			CommandRegistry.Add((ConsoleCommand)(object)new RepairCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new TwinKnivesCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new CrowCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new TestJobCommand());
			CommandRegistry.Add((ConsoleCommand)(object)new WeaponsCommand());
			CommandRegistry.RefreshConsole();
			Staffs.Register();
			JobWeapons.Register();
			TwinKnives.Register();
			HunterItems.Register();
			JobAltar.Register();
			JobShrines.Register();
			SpellVisuals.Register();
			NapalmBeat.Register();
			ThiefVisuals.Register();
			Stun.Register();
			SwordmanVisuals.Register();
			ProvokeVisuals.Register();
			LevelUpVisuals.Register();
			ArcherVisuals.Register();
			SecondJobVisuals.Register();
			ThunderstormVisuals.Register();
			WizardVisuals.Register();
			KnightVisuals.Register();
			AssassinVisuals.Register();
			HunterVisuals.Register();
			AcolyteVisuals.Register();
			PriestVisuals.Register();
			AcolyteBuffs.Register();
			Poring.Register();
			ModMusic.Create();
			MemoMarks.Create();
			BuffIcons.Register();
			((Component)this).gameObject.AddComponent<SkillInput>();
			((Component)this).gameObject.AddComponent<JobShrineRepair>();
			SeneaLBridge.Register();
			SkillShout.RegisterRpc();
			VanillaPrefabs.WhenReady(PoringSpawns.AttachAll);
			VanillaPrefabs.WhenReady(SkeletonSpawns.AttachAll);
			Assassin.RegisterRpc();
			PatchAll();
			Log.LogInfo((object)"Ragnarok RPG 0.8.5 loaded");
		}

		private void PatchAll()
		{
			int num = 0;
			Type[] typesFromAssembly = AccessTools.GetTypesFromAssembly(typeof(Plugin).Assembly);
			foreach (Type type in typesFromAssembly)
			{
				if (type.IsDefined(typeof(HarmonyPatch), inherit: false))
				{
					try
					{
						_harmony.CreateClassProcessor(type).Patch();
					}
					catch (Exception ex)
					{
						num++;
						Log.LogError((object)("Patch " + type.Name + " failed, skipped: " + ex.GetBaseException().Message));
					}
				}
			}
			if (num > 0)
			{
				Log.LogError((object)$"{num} patch(es) failed: see above");
			}
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
			HandSlotDrag.Disabled = true;
			SkillWindow.Destroy();
			JobAltarWindow.Destroy();
			WarpPortalWindow.Destroy();
			FallenWindow.Destroy();
			Fallen.Clear(Player.m_localPlayer);
			MemoMarks.Destroy();
			StatusWindow.Destroy();
			SkillBarHud.Destroy();
			RoDamageNumbers.Destroy();
			SeneaLBridge.Unregister();
			PoringSpawns.Detach();
			SkeletonSpawns.Detach();
			ModMusic.Destroy();
			Log.LogInfo((object)"Ragnarok RPG 0.8.5 unloaded");
		}
	}
	public class SkillInput : MonoBehaviour
	{
		private void Update()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			SkillBarHud.EnsureCreated();
			Thief.Update(localPlayer);
			Assassin.Update(localPlayer);
			Hunter.Update(localPlayer);
			BuffMacro.Update(localPlayer);
			if ((Object)(object)localPlayer == (Object)null || IsTyping())
			{
				return;
			}
			KeyboardShortcut value = ModConfig.SkillWindowKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				SkillWindow.Toggle();
			}
			value = ModConfig.StatusWindowKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				StatusWindow.Toggle();
			}
			if (SkillWindow.IsOpen || StatusWindow.IsOpen || Pad(localPlayer))
			{
				return;
			}
			value = ModConfig.SkillStackKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				SkillBar.NextStack();
			}
			value = ModConfig.ItemBarKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				SkillBar.ShowItems();
			}
			if (!((Character)localPlayer).TakeInput())
			{
				return;
			}
			bool altHeld = SkillBar.AltHeld;
			if (SkillBar.InSkillMode == altHeld)
			{
				return;
			}
			int stack = (SkillBar.InSkillMode ? SkillBar.Mode : SkillBar.ShownStack);
			for (int i = 0; i < 8; i++)
			{
				if (ZInput.GetButtonDown($"Hotbar{i + 1}"))
				{
					SkillBar.CastSlot(localPlayer, stack, i);
				}
			}
		}

		private static bool Pad(Player player)
		{
			if (PadInput.PageLayer)
			{
				if (PadInput.Down("JoyButtonY"))
				{
					SkillWindow.Open();
				}
				else if (PadInput.Down("JoyButtonX"))
				{
					StatusWindow.Open();
				}
				return true;
			}
			if (!PadInput.CastLayer)
			{
				return false;
			}
			int num = PadInput.FacePressed();
			if (num >= 0)
			{
				SkillBar.CastPadSlot(player, num);
			}
			else if (PadInput.Down("JoyDPadDown"))
			{
				SkillBar.StepPadPage(1);
			}
			else if (PadInput.Down("JoyDPadUp"))
			{
				SkillBar.StepPadPage(-1);
			}
			return true;
		}

		private static bool IsTyping()
		{
			if (!Console.IsVisible() && !TextInput.IsVisible() && !Menu.IsVisible())
			{
				if ((Object)(object)Chat.instance != (Object)null)
				{
					return Chat.instance.HasFocus();
				}
				return false;
			}
			return true;
		}
	}
	public static class VanillaPrefabs
	{
		public static bool Ready
		{
			get
			{
				if ((Object)(object)ObjectDB.instance != (Object)null)
				{
					return (Object)(object)ObjectDB.instance.GetItemPrefab("StaffIceShards") != (Object)null;
				}
				return false;
			}
		}

		public static void WhenReady(Action action)
		{
			if (Ready)
			{
				action();
			}
			else
			{
				PrefabManager.OnVanillaPrefabsAvailable += Once;
			}
			void Once()
			{
				PrefabManager.OnVanillaPrefabsAvailable -= Once;
				action();
			}
		}

		public static GameObject Existing(string name)
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab(name);
			if (Object.op_Implicit((Object)(object)prefab))
			{
				ReplaceStaleComponents(prefab);
			}
			return prefab;
		}

		public static void ReplaceStaleComponents(GameObject go)
		{
			Assembly assembly = typeof(VanillaPrefabs).Assembly;
			MonoBehaviour[] componentsInChildren = go.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				Type type = ((object)val).GetType();
				if (type.Assembly == assembly || type.Namespace == null || !type.Namespace.StartsWith("RagnarokJobs"))
				{
					continue;
				}
				Type type2 = assembly.GetType(type.FullName);
				GameObject gameObject = ((Component)val).gameObject;
				if (type2 != null)
				{
					Component obj = gameObject.AddComponent(type2);
					FieldInfo[] fields = type2.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (FieldInfo fieldInfo in fields)
					{
						FieldInfo field = type.GetField(fieldInfo.Name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (!(field == null))
						{
							if (field.FieldType == fieldInfo.FieldType)
							{
								fieldInfo.SetValue(obj, field.GetValue(val));
							}
							else if (field.FieldType.IsEnum && fieldInfo.FieldType.IsEnum)
							{
								fieldInfo.SetValue(obj, Enum.ToObject(fieldInfo.FieldType, Convert.ToInt64(field.GetValue(val))));
							}
						}
					}
				}
				Object.DestroyImmediate((Object)(object)val, true);
			}
		}
	}
}
namespace RagnarokJobs.Ui
{
	public class FallenWindow : MonoBehaviour
	{
		private static FallenWindow _instance;

		private GameObject _canvasRoot;

		private PadNav _pad;

		private TextMeshProUGUI _status;

		private Button _wait;

		private TextMeshProUGUI _waitLabel;

		private bool _waiting;

		public static bool IsOpen
		{
			get
			{
				if ((Object)(object)_instance != (Object)null)
				{
					return _instance._canvasRoot.activeSelf;
				}
				return false;
			}
		}

		public static void Open()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if ((Object)(object)_instance == (Object)null)
			{
				GameObject val = new GameObject("RagnarokJobs_FallenWindow");
				Object.DontDestroyOnLoad((Object)val);
				_instance = val.AddComponent<FallenWindow>();
				_instance.Build();
			}
			_instance._waiting = false;
			((Selectable)_instance._wait).interactable = true;
			if (!IsOpen)
			{
				GUIManager.BlockInput(true);
			}
			_instance._canvasRoot.SetActive(true);
			_instance.Refresh();
		}

		public static void Close()
		{
			if (IsOpen)
			{
				_instance._canvasRoot.SetActive(false);
				GUIManager.BlockInput(false);
			}
		}

		public static void Destroy()
		{
			if (!((Object)(object)_instance == (Object)null))
			{
				Close();
				Object.Destroy((Object)(object)((Component)_instance).gameObject);
				_instance = null;
			}
		}

		private void Build()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			_canvasRoot = new GameObject("Canvas", new Type[1] { typeof(RectTransform) });
			_canvasRoot.transform.SetParent(((Component)this).transform, false);
			_pad = new PadNav((RectTransform)_canvasRoot.transform, null);
			_pad.Preferred = "Panel/Wait";
			Canvas obj = _canvasRoot.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 130;
			CanvasScaler obj2 = _canvasRoot.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			obj2.matchWidthOrHeight = 0.5f;
			obj2.referencePixelsPerUnit = SeneaLBridge.PixelsPerUnit;
			_canvasRoot.AddComponent<GraphicRaycaster>();
			RectTransform val = UiFactory.Place(UiFactory.Rect("Panel", _canvasRoot.transform), new Vector2(0.5f, 0.3f), Vector2.zero, new Vector2(560f, 230f));
			UiFactory.Image(val, UiFactory.PanelColor, (ThemePart)0);
			((TMP_Text)UiFactory.Text((Transform)(object)UiFactory.Place(UiFactory.Rect("Title", (Transform)(object)val), new Vector2(0.5f, 1f), new Vector2(0f, -36f), new Vector2(500f, 40f)), "Text", 26f, (TextAlignmentOptions)514, UiFactory.TextColor, strong: true)).SetText("You have fallen");
			RectTransform parent = UiFactory.Place(UiFactory.Rect("Status", (Transform)(object)val), new Vector2(0.5f, 1f), new Vector2(0f, -86f), new Vector2(500f, 50f));
			_status = UiFactory.Text((Transform)(object)parent, "Text", 18f, (TextAlignmentOptions)514, UiFactory.MutedColor);
			_wait = UiFactory.Button(UiFactory.Place(UiFactory.Rect("Wait", (Transform)(object)val), new Vector2(0.5f, 0f), new Vector2(-128f, 50f), new Vector2(240f, 50f)), "Wait for resurrection", 18f, Wait, primary: true);
			_waitLabel = ((Component)_wait).GetComponentInChildren<TextMeshProUGUI>();
			UiFactory.Button(UiFactory.Place(UiFactory.Rect("Bed", (Transform)(object)val), new Vector2(0.5f, 0f), new Vector2(128f, 50f), new Vector2(240f, 50f)), "Back to bed", 18f, BackToBed);
			_canvasRoot.SetActive(false);
		}

		private void Wait()
		{
			_waiting = true;
			((Selectable)_wait).interactable = false;
			Refresh();
		}

		private void BackToBed()
		{
			Close();
			Fallen.Die(Player.m_localPlayer);
		}

		private void Update()
		{
			if (IsOpen)
			{
				_pad.Update();
			}
			if (IsOpen)
			{
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null || !Fallen.IsFallen((Character)(object)localPlayer))
				{
					Close();
				}
				else
				{
					Refresh();
				}
			}
		}

		private void Refresh()
		{
			int num = Mathf.CeilToInt(Fallen.SecondsLeft);
			((TMP_Text)_status).SetText(_waiting ? $"Waiting for a Priest's Resurrection: {num} s.\nIf none comes, you return to your bed." : $"A Priest nearby can raise you within {num} s, with no death penalty.\nOr return to your bed now (a normal death).");
			((TMP_Text)_waitLabel).SetText(_waiting ? $"Waiting… {num} s" : "Wait for resurrection");
		}
	}
	public class JobAltarWindow : MonoBehaviour
	{
		private static readonly Job[] Jobs = new Job[5]
		{
			Job.Swordman,
			Job.Archer,
			Job.Mage,
			Job.Thief,
			Job.Acolyte
		};

		private static readonly Dictionary<Job, string> Blurbs = new Dictionary<Job, string>
		{
			{
				Job.Swordman,
				"Sword and shield. Bash, Magnum Break, Endure."
			},
			{
				Job.Archer,
				"Bow. Double Strafe, Arrow Shower, Owl's Eye."
			},
			{
				Job.Mage,
				"Staff and eitr. Bolts, Napalm Beat, Frost Diver."
			},
			{
				Job.Thief,
				"Knife. Double Attack, Envenom, Hiding, Steal."
			},
			{
				Job.Acolyte,
				"Staff or mace. Heal, Blessing, Increase AGI, Holy Light."
			},
			{
				Job.Knight,
				"Swordman's 2nd job. Bowling Bash; more melee damage and health."
			},
			{
				Job.Hunter,
				"Archer's 2nd job. Blitz Beat and the falcon; more bow damage and stamina."
			},
			{
				Job.Wizard,
				"Mage's 2nd job. Storm Gust; MATK and eitr keep growing."
			},
			{
				Job.Assassin,
				"Thief's 2nd job. Sonic Blow; more knife damage and evade."
			},
			{
				Job.Priest,
				"Acolyte's 2nd job. Sanctuary, Kyrie Eleison, Magnus Exorcismus, Resurrection; buffs for the group."
			}
		};

		private static JobAltarWindow _instance;

		private GameObject _canvasRoot;

		private PadNav _pad;

		private RectTransform _panel;

		private TextMeshProUGUI _title;

		private RectTransform _advanceRow;

		private bool _valkyrie;

		private TextMeshProUGUI _status;

		private readonly List<(Job job, Button button, Image emblem, TextMeshProUGUI note)> _rows = new List<(Job, Button, Image, TextMeshProUGUI)>();

		private Button _replace;

		private TextMeshProUGUI _replaceNote;

		private Button _advance;

		private TextMeshProUGUI _advanceLabel;

		private Image _advanceEmblem;

		private TextMeshProUGUI _advanceBlurb;

		private TextMeshProUGUI _advanceNote;

		private TextMeshProUGUI _hint;

		private bool? _hintShown;

		public static bool IsOpen
		{
			get
			{
				if ((Object)(object)_instance != (Object)null)
				{
					return _instance._canvasRoot.activeSelf;
				}
				return false;
			}
		}

		public static void Open(bool valkyrie = false)
		{
			//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_002b: Expected O, but got Unknown
			if (!((Object)(object)Player.m_localPlayer == (Object)null))
			{
				if ((Object)(object)_instance == (Object)null)
				{
					GameObject val = new GameObject("RagnarokJobs_JobAltarWindow");
					Object.DontDestroyOnLoad((Object)val);
					_instance = val.AddComponent<JobAltarWindow>();
					_instance.Build();
				}
				_instance._valkyrie = valkyrie;
				_instance.Layout();
				_instance._canvasRoot.SetActive(true);
				GUIManager.BlockInput(true);
				_instance.Refresh();
			}
		}

		public static void Close()
		{
			if (IsOpen)
			{
				_instance._canvasRoot.SetActive(false);
				GUIManager.BlockInput(false);
			}
		}

		public static void Destroy()
		{
			if (!((Object)(object)_instance == (Object)null))
			{
				Close();
				Object.Destroy((Object)(object)((Component)_instance).gameObject);
				_instance = null;
			}
		}

		private void Update()
		{
			if (IsOpen)
			{
				_pad.Update();
			}
			if (IsOpen)
			{
				ShowHint();
			}
			if (IsOpen && (Object)(object)Player.m_localPlayer == (Object)null)
			{
				Close();
			}
		}

		private void Build()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_074f: Unknown result type (might be due to invalid IL or missing references)
			//IL_075e: Unknown result type (might be due to invalid IL or missing references)
			//IL_077c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			_canvasRoot = new GameObject("Canvas", new Type[1] { typeof(RectTransform) });
			_canvasRoot.transform.SetParent(((Component)this).transform, false);
			_pad = new PadNav((RectTransform)_canvasRoot.transform, Close);
			Canvas obj = _canvasRoot.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 120;
			CanvasScaler obj2 = _canvasRoot.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			obj2.matchWidthOrHeight = 0.5f;
			obj2.referencePixelsPerUnit = SeneaLBridge.PixelsPerUnit;
			_canvasRoot.AddComponent<GraphicRaycaster>();
			RectTransform val = (_panel = UiFactory.Place(UiFactory.Rect("Panel", _canvasRoot.transform), new Vector2(0.5f, 0.5f), Vector2.zero, new Vector2(720f, 712f)));
			UiFactory.Image(val, UiFactory.PanelColor, (ThemePart)0);
			RectTransform parent = UiFactory.Place(UiFactory.Rect("Title", (Transform)(object)val), new Vector2(0f, 1f), new Vector2(28f, -20f), new Vector2(600f, 40f));
			_title = UiFactory.Text((Transform)(object)parent, "Text", 24f, (TextAlignmentOptions)4097, UiFactory.TextColor, strong: true);
			UiFactory.Button(UiFactory.Place(UiFactory.Rect("Close", (Transform)(object)val), new Vector2(1f, 1f), new Vector2(-18f, -18f), new Vector2(40f, 40f)), "X", 20f, Close);
			RectTransform parent2 = UiFactory.Place(UiFactory.Rect("Status", (Transform)(object)val), new Vector2(0f, 1f), new Vector2(28f, -64f), new Vector2(664f, 56f));
			_status = UiFactory.Text((Transform)(object)parent2, "Text", 17f, (TextAlignmentOptions)257, UiFactory.MutedColor);
			for (int i = 0; i < Jobs.Length; i++)
			{
				Job job = Jobs[i];
				float num = -130f - (float)i * 92f;
				RectTransform val2 = UiFactory.Place(UiFactory.Rect(job.ToString() + "Row", (Transform)(object)val), new Vector2(0f, 1f), new Vector2(28f, num), new Vector2(664f, 82f));
				UiFactory.Image(val2, UiFactory.RowColor);
				Image item = ModIcons.Emblem(UiFactory.Place(UiFactory.Rect("Emblem", (Transform)(object)val2), new Vector2(0f, 0.5f), new Vector2(10f, 0f), new Vector2(64f, 64f)));
				Button item2 = UiFactory.Button(UiFactory.Place(UiFactory.Rect("Button", (Transform)(object)val2), new Vector2(0f, 0.5f), new Vector2(82f, 0f), new Vector2(170f, 52f)), job.ToString(), 20f, delegate
				{
					Choose(job);
				}, primary: true);
				((TMP_Text)UiFactory.Text((Transform)(object)UiFactory.Place(UiFactory.Rect("Blurb", (Transform)(object)val2), new Vector2(0f, 1f), new Vector2(266f, -8f), new Vector2(390f, 34f)), "Text", 16f, (TextAlignmentOptions)257, UiFactory.TextColor)).SetText(Blurbs[job]);
				TextMeshProUGUI item3 = UiFactory.Text((Transform)(object)UiFactory.Place(UiFactory.Rect("Note", (Transform)(object)val2), new Vector2(0f, 0f), new Vector2(266f, 8f), new Vector2(390f, 34f)), "Text", 15f, (TextAlignmentOptions)1025, UiFactory.MutedColor);
				_rows.Add((job, item2, item, item3));
			}
			RectTransform val3 = (_advanceRow = UiFactory.Place(UiFactory.Rect("AdvanceRow", (Transform)(object)val), new Vector2(0f, 1f), new Vector2(28f, -130f - (float)Jobs.Length * 92f - 8f), new Vector2(664f, 82f)));
			UiFactory.Image(val3, UiFactory.RowOnColor);
			_advanceEmblem = ModIcons.Emblem(UiFactory.Place(UiFactory.Rect("Emblem", (Transform)(object)val3), new Vector2(0f, 0.5f), new Vector2(10f, 0f), new Vector2(64f, 64f)));
			_advance = UiFactory.Button(UiFactory.Place(UiFactory.Rect("Button", (Transform)(object)val3), new Vector2(0f, 0.5f), new Vector2(82f, 0f), new Vector2(170f, 52f)), "Advance", 20f, AdvanceOrReturn, primary: true);
			_advanceLabel = ((Component)_advance).GetComponentInChildren<TextMeshProUGUI>();
			RectTransform parent3 = UiFactory.Place(UiFactory.Rect("Blurb", (Transform)(object)val3), new Vector2(0f, 1f), new Vector2(266f, -8f), new Vector2(390f, 34f));
			_advanceBlurb = UiFactory.Text((Transform)(object)parent3, "Text", 16f, (TextAlignmentOptions)257, UiFactory.TextColor);
			RectTransform parent4 = UiFactory.Place(UiFactory.Rect("Note", (Transform)(object)val3), new Vector2(0f, 0f), new Vector2(266f, 8f), new Vector2(390f, 34f));
			_advanceNote = UiFactory.Text((Transform)(object)parent4, "Text", 15f, (TextAlignmentOptions)1025, UiFactory.MutedColor);
			RectTransform parent5 = UiFactory.Place(UiFactory.Rect("ReplaceRow", (Transform)(object)val), new Vector2(0f, 0f), new Vector2(28f, 44f), new Vector2(664f, 60f));
			_replace = UiFactory.Button(UiFactory.Place(UiFactory.Rect("Button", (Transform)(object)parent5), new Vector2(0f, 0.5f), new Vector2(12f, 0f), new Vector2(190f, 44f)), "Replace weapon", 17f, Replace);
			RectTransform parent6 = UiFactory.Place(UiFactory.Rect("Note", (Transform)(object)parent5), new Vector2(0f, 0.5f), new Vector2(220f, 0f), new Vector2(430f, 44f));
			_replaceNote = UiFactory.Text((Transform)(object)parent6, "Text", 15f, (TextAlignmentOptions)4097, UiFactory.MutedColor);
			RectTransform parent7 = UiFactory.Place(UiFactory.Rect("Hint", (Transform)(object)val), new Vector2(0f, 0f), new Vector2(28f, 12f), new Vector2(664f, 24f));
			_hint = UiFactory.Text((Transform)(object)parent7, "Text", 15f, (TextAlignmentOptions)4097, UiFactory.MutedColor);
			_canvasRoot.SetActive(false);
		}

		private void Layout()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)_title).SetText(_valkyrie ? "Valkyrie Statue" : "Job Altar");
			foreach (var row in _rows)
			{
				((Component)((Component)row.button).transform.parent).gameObject.SetActive(!_valkyrie);
			}
			((Component)((Component)_replace).transform.parent).gameObject.SetActive(!_valkyrie);
			_advanceRow.anchoredPosition = new Vector2(28f, _valkyrie ? (-130f) : (-130f - (float)Jobs.Length * 92f - 8f));
			_panel.sizeDelta = new Vector2(720f, _valkyrie ? 270f : 732f);
			_pad.Preferred = (_valkyrie ? "Panel/AdvanceRow/Button" : $"Panel/{Jobs[0]}Row/Button");
		}

		private void ShowHint()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ZInput.IsGamepadActive() && ModConfig.GamepadControls.Value;
			if (_hintShown != flag)
			{
				_hintShown = flag;
				string text = "<color=#" + ColorUtility.ToHtmlStringRGB(UiFactory.AccentColor) + ">";
				((TMP_Text)_hint).SetText(flag ? (text + "D-pad</color>: move   " + text + "A</color>: choose   " + text + "B</color>: close") : "");
			}
		}

		private void Choose(Job job)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null && JobChange.TryChange(localPlayer, job))
			{
				Close();
			}
			else
			{
				Refresh();
			}
		}

		private void AdvanceOrReturn()
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				if (JobInfo.IsSecondJob(JobData.GetJob(localPlayer)) ? JobChange.TryRevert(localPlayer) : JobChange.TryAdvance(localPlayer))
				{
					Close();
				}
				else
				{
					Refresh();
				}
			}
		}

		private void Replace()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				JobChange.TryReplace(localPlayer);
			}
			Refresh();
		}

		private void Refresh()
		{
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			Job job = JobData.GetJob(localPlayer);
			Job job2 = JobInfo.SecondJobOf(job);
			if (_valkyrie)
			{
				RefreshAdvance(localPlayer, job, job2);
				((TMP_Text)_status).SetText((job == Job.Novice) ? "The Valkyrie judges those who already walk a path. Take a job at Freya's Job Altar first." : ((JobInfo.Tier(job) == 1) ? $"{job}, prove yourself and the Valkyrie raises you to {JobInfo.SecondJobName(job)}." : ($"You are a {job}. The Valkyrie can return you to {JobInfo.FirstJobOf(job)}; your {job} levels " + "and skills wait for you, and advancing again is free.")));
				return;
			}
			((TMP_Text)_status).SetText((job == Job.Novice) ? $"You are a Novice, Job Lv {JobData.GetJobLevel(localPlayer, Job.Novice)}/{10}. Choose your path: the job's weapon is your reward." : (JobInfo.IsSecondJob(job) ? ($"You are a {job}. Freya only changes 1st jobs: the Valkyrie where Moder fell can return you to " + $"{JobInfo.FirstJobOf(job)} first.") : ($"You are a {job}. To change job, trade in your {JobWeapons.Name(job)}. Job levels and skills are kept per job." + ((JobInfo.Tier(job) == 1) ? $" To become a {job2}, seek the Valkyrie where Moder fell." : ""))));
			foreach (var row in _rows)
			{
				Job item = row.job;
				Button item2 = row.button;
				Image item3 = row.emblem;
				TextMeshProUGUI item4 = row.note;
				Job job3 = ((JobInfo.FirstJobOf(job) == item) ? job : item);
				string text = JobChange.Blocker(localPlayer, item);
				((Selectable)item2).interactable = text == null;
				TextMeshProUGUI componentInChildren = ((Component)item2).GetComponentInChildren<TextMeshProUGUI>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					((TMP_Text)componentInChildren).SetText(job3.ToString());
				}
				ModIcons.Show(item3, ModIcons.Job(job3));
				((Graphic)item3).color = (Color)((text == null || item == JobInfo.FirstJobOf(job)) ? Color.white : new Color(0.5f, 0.5f, 0.5f, 0.8f));
				((Graphic)item4).color = ((text == null) ? UiFactory.GoodColor : UiFactory.MutedColor);
				((TMP_Text)item4).SetText(text ?? ("Receive: " + JobWeapons.Name(item) + ((job == Job.Novice) ? "" : $"  (Job Lv {JobData.GetJobLevel(localPlayer, job3)})")));
			}
			((Component)_advanceRow).gameObject.SetActive(false);
			string text2 = JobChange.ReplaceBlocker(localPlayer);
			((Component)_replace).gameObject.SetActive(JobInfo.IsFirstJob(job));
			((Selectable)_replace).interactable = text2 == null;
			((TMP_Text)_replaceNote).SetText(JobInfo.IsFirstJob(job) ? (((JobWeapons.All(job).Length > 1) ? ("Lost your " + JobWeapons.Name(job) + "? A new pair costs 1 Hard antler; the old ones crumble.") : ("Lost your " + JobWeapons.Name(job) + "? A new one costs 1 Hard antler; the old one crumbles.")) + ((text2 != null) ? (" (" + text2 + ")") : "")) : "");
		}

		private void RefreshAdvance(Player player, Job current, Job next)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			bool flag = JobInfo.IsSecondJob(current);
			Job job = (flag ? JobInfo.FirstJobOf(current) : next);
			string text = (flag ? JobChange.RevertBlocker(player) : JobData.AdvanceBlocker(player));
			((Component)_advanceRow).gameObject.SetActive(JobInfo.Tier(current) >= 1);
			((Selectable)_advance).interactable = text == null;
			TextMeshProUGUI advanceLabel = _advanceLabel;
			if (advanceLabel != null)
			{
				((TMP_Text)advanceLabel).SetText(flag ? $"Return: {job}" : ("Advance: " + JobInfo.SecondJobName(current)));
			}
			ModIcons.Show(_advanceEmblem, ModIcons.Job(job));
			((Graphic)_advanceEmblem).color = (Color)((text == null) ? Color.white : new Color(0.5f, 0.5f, 0.5f, 0.8f));
			((TMP_Text)_advanceBlurb).SetText(Blurbs.TryGetValue(job, out var value) ? value : "");
			((Graphic)_advanceNote).color = ((text == null) ? UiFactory.GoodColor : UiFactory.MutedColor);
			((TMP_Text)_advanceNote).SetText(text ?? (flag ? $"Costs 1 Moder trophy. Your {current} levels and skills are kept." : $"Keeps your {current} skills and weapon. Needs {current} Job Lv {40}."));
		}
	}
	public class MemoMarks : MonoBehaviour
	{
		private static MemoMarks _instance;

		private GameObject _template;

		private readonly Dictionary<int, (GameObject mark, Vector3 pos)> _marks = new Dictionary<int, (GameObject, Vector3)>();

		private float _next;

		public static void Create()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_instance))
			{
				GameObject val = new GameObject("RagnarokJobs_MemoMarks");
				Object.DontDestroyOnLoad((Object)val);
				_instance = val.AddComponent<MemoMarks>();
			}
		}

		public static void Destroy()
		{
			if (Object.op_Implicit((Object)(object)_instance))
			{
				_instance.Clear();
				if (Object.op_Implicit((Object)(object)_instance._template))
				{
					Object.Destroy((Object)(object)_instance._template);
				}
				Object.Destroy((Object)(object)((Component)_instance).gameObject);
				_instance = null;
			}
		}

		private void Clear()
		{
			foreach (var value in _marks.Values)
			{
				if (Object.op_Implicit((Object)(object)value.mark))
				{
					Object.Destroy((Object)(object)value.mark);
				}
			}
			_marks.Clear();
		}

		private void Update()
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time < _next)
			{
				return;
			}
			_next = Time.time + 0.5f;
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				Clear();
				return;
			}
			for (int i = 1; i <= 3; i++)
			{
				Vector3 pos;
				bool flag = WarpPortalWindow.TryGetMemo(localPlayer, i, out pos);
				_marks.TryGetValue(i, out (GameObject, Vector3) value);
				if (flag && Object.op_Implicit((Object)(object)value.Item1) && value.Item2 == pos)
				{
					continue;
				}
				if (Object.op_Implicit((Object)(object)value.Item1))
				{
					Object.Destroy((Object)(object)value.Item1);
				}
				_marks.Remove(i);
				if (flag)
				{
					if (!Object.op_Implicit((Object)(object)_template))
					{
						_template = AcolyteVisuals.BuildMemoMark();
					}
					GameObject val = Object.Instantiate<GameObject>(_template, pos, Quaternion.identity);
					val.SetActive(true);
					_marks[i] = (val, pos);
				}
			}
		}
	}
	public sealed class PadNav
	{
		public struct Target
		{
			public RectTransform Rect;

			public Action Press;

			public Action Alt;
		}

		private readonly RectTransform _root;

		private readonly Action _back;

		private readonly Func<IEnumerable<Target>> _extra;

		private readonly List<Target> _targets = new List<Target>();

		private readonly List<Button> _buttons = new List<Button>();

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

		private RectTransform _frame;

		private string _focus;

		private Vector2 _lastCentre;

		private int _lastFrame = -10;

		private static readonly string[] FaceButtons = new string[6] { "JoyButtonA", "JoyButtonB", "JoyButtonX", "JoyUse", "JoyJump", "JoyDodge" };

		public string Preferred;

		public PadNav(RectTransform root, Action back, Func<IEnumerable<Target>> extra = null)
		{
			_root = root;
			_back = back;
			_extra = extra;
		}

		public void Update()
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Time.frameCount > _lastFrame + 1;
			_lastFrame = Time.frameCount;
			if (!ZInput.IsGamepadActive() || !ModConfig.GamepadControls.Value)
			{
				ShowFrame(null);
				return;
			}
			if (flag)
			{
				Consume();
				_focus = null;
			}
			else if (ZInput.GetButtonDown("JoyButtonB"))
			{
				Consume();
				_back?.Invoke();
				return;
			}
			Gather();
			int num = Find(_focus);
			if (num < 0 && _targets.Count > 0)
			{
				num = Find(Preferred);
				if (num < 0)
				{
					num = ((flag || _lastCentre == Vector2.zero) ? TopLeft() : Nearest(_lastCentre));
				}
				_focus = Path((Transform)(object)_targets[num].Rect);
			}
			if (num < 0)
			{
				ShowFrame(null);
				return;
			}
			Vector2 val = Direction();
			if (val != Vector2.zero)
			{
				int num2 = Step(num, val);
				if (num2 >= 0)
				{
					num = num2;
					_focus = Path((Transform)(object)_targets[num].Rect);
				}
			}
			Target target = _targets[num];
			ScrollIntoView(target.Rect);
			_lastCentre = Centre(target.Rect);
			ShowFrame(target.Rect);
			if (!flag)
			{
				if (ZInput.GetButtonDown("JoyButtonA"))
				{
					Consume();
					target.Press?.Invoke();
				}
				else if (ZInput.GetButtonDown("JoyButtonX"))
				{
					Consume();
					target.Alt?.Invoke();
				}
			}
		}

		private static void Consume()
		{
			string[] faceButtons = FaceButtons;
			for (int i = 0; i < faceButtons.Length; i++)
			{
				ZInput.ResetButtonStatus(faceButtons[i]);
			}
			PlayerController.SetTakeInputDelay(0.25f);
		}

		public void Hide()
		{
			ShowFrame(null);
		}

		private void Gather()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			_targets.Clear();
			((Component)_root).GetComponentsInChildren<Button>(false, _buttons);
			foreach (Button button2 in _buttons)
			{
				if (((Selectable)button2).IsInteractable() && ((Behaviour)button2).isActiveAndEnabled)
				{
					Button button = button2;
					_targets.Add(new Target
					{
						Rect = (RectTransform)((Component)button2).transform,
						Press = delegate
						{
							((UnityEvent)button.onClick).Invoke();
						}
					});
				}
			}
			if (_extra == null)
			{
				return;
			}
			foreach (Target item in _extra())
			{
				if (Object.op_Implicit((Object)(object)item.Rect) && ((Component)item.Rect).gameObject.activeInHierarchy)
				{
					_targets.Add(item);
				}
			}
		}

		private static Vector2 Direction()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (ZInput.GetButtonDown("JoyDPadUp") || ZInput.GetButtonDown("JoyLStickUp"))
			{
				return Vector2.up;
			}
			if (ZInput.GetButtonDown("JoyDPadDown") || ZInput.GetButtonDown("JoyLStickDown"))
			{
				return Vector2.down;
			}
			if (ZInput.GetButtonDown("JoyDPadLeft") || ZInput.GetButtonDown("JoyLStickLeft"))
			{
				return Vector2.left;
			}
			if (ZInput.GetButtonDown("JoyDPadRight") || ZInput.GetButtonDown("JoyLStickRight"))
			{
				return Vector2.right;
			}
			return Vector2.zero;
		}

		private int Step(int from, Vector2 dir)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0068: 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)
			Vector2 val = Centre(_targets[from].Rect);
			int result = -1;
			float num = float.MaxValue;
			for (int i = 0; i < _targets.Count; i++)
			{
				if (i == from)
				{
					continue;
				}
				Vector2 val2 = Centre(_targets[i].Rect) - val;
				float num2 = Vector2.Dot(val2, dir);
				if (!(num2 <= 1f))
				{
					float num3 = Mathf.Abs(val2.x * dir.y - val2.y * dir.x);
					float num4 = num2 + num3 * 2f;
					if (num4 < num)
					{
						num = num4;
						result = i;
					}
				}
			}
			return result;
		}

		private int TopLeft()
		{
			//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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_0069: 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_007d: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			int num = -1;
			for (int i = 0; i < _targets.Count; i++)
			{
				if (((Object)_targets[i].Rect).name == "Close")
				{
					continue;
				}
				if (num < 0)
				{
					num = i;
					continue;
				}
				Vector2 val = Centre(_targets[i].Rect);
				Vector2 val2 = Centre(_targets[num].Rect);
				if (val.y > val2.y + 1f || (Mathf.Abs(val.y - val2.y) <= 1f && val.x < val2.x))
				{
					num = i;
				}
			}
			if (num >= 0)
			{
				return num;
			}
			return 0;
		}

		private int Nearest(Vector2 point)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			int result = 0;
			float num = float.MaxValue;
			for (int i = 0; i < _targets.Count; i++)
			{
				Vector2 val = Centre(_targets[i].Rect) - point;
				float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					result = i;
				}
			}
			return result;
		}

		private int Find(string path)
		{
			if (string.IsNullOrEmpty(path))
			{
				return -1;
			}
			for (int i = 0; i < _targets.Count; i++)
			{
				if (Path((Transform)(object)_targets[i].Rect) == path)
				{
					return i;
				}
			}
			return -1;
		}

		private string Path(Transform t)
		{
			string text = ((Object)t).name;
			Transform parent = t.parent;
			while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)_root)
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		private Vector2 Centre(RectTransform rt)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_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)
			rt.GetWorldCorners(_corners);
			return Vector2.op_Implicit((_corners[0] + _corners[2]) * 0.5f);
		}

		private void ScrollIntoView(RectTransform rt)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			ScrollRect componentInParent = ((Component)rt).GetComponentInParent<ScrollRect>();
			if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent.content == (Object)null) && ((Transform)rt).IsChildOf((Transform)(object)componentInParent.content))
			{
				object obj = (Object.op_Implicit((Object)(object)componentInParent.viewport) ? ((object)componentInParent.viewport) : ((object)(RectTransform)((Component)componentInParent).transform));
				rt.GetWorldCorners(_corners);
				float y = _corners[1].y;
				float y2 = _corners[0].y;
				((RectTransform)obj).GetWorldCorners(_corners);
				float y3 = _corners[1].y;
				float y4 = _corners[0].y;
				float num = ((y > y3) ? (y - y3) : ((y2 < y4) ? (y2 - y4) : 0f));
				if (num != 0f)
				{
					float y5 = ((Transform)componentInParent.content).lossyScale.y;
					componentInParent.velocity = Vector2.zero;
					RectTransform content = componentInParent.content;
					content.anchoredPosition -= new Vector2(0f, num / ((y5 > 0f) ? y5 : 1f));
				}
			}
		}

		private void ShowFrame(RectTransform target)
		{
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)target == (Object)null)
			{
				if (Object.op_Implicit((Object)(object)_frame))
				{
					((Component)_frame).gameObject.SetActive(false);
				}
				return;
			}
			if (!Object.op_Implicit((Object)(object)_frame))
			{
				_frame = UiFactory.Rect("PadFocus", (Transform)(object)_root);
				for (int i = 0; i < 4; i++)
				{
					RectTransform obj = UiFactory.Rect("Edge" + i, (Transform)(object)_frame);
					Image obj2 = ((Component)obj).gameObject.AddComponent<Image>();
					obj2.sprite = UiFactory.White;
					((Graphic)obj2).color = UiFactory.AccentColor;
					((Graphic)obj2).raycastTarget = false;
					obj.anchorMin = new Vector2((i == 1) ? 1f : 0f, (i == 2) ? 1f : 0f);
					obj.anchorMax = new Vector2((i == 3) ? 0f : 1f, (i == 0) ? 0f : 1f);
					obj.pivot = new Vector2((i == 1) ? 1f : 0f, (i == 2) ? 1f : 0f);
					obj.sizeDelta = new Vector2((i == 1 || i == 3) ? 3f : 0f, (i == 0 || i == 2) ? 3f : 0f);
					obj.anchoredPosition = Vector2.zero;
				}
			}
			((Component)_frame).gameObject.SetActive(true);
			((Transform)_frame).SetAsLastSibling();
			target.GetWorldCorners(_corners);
			Vector2 val = Vector2.op_Implicit(((Transform)_root).InverseTransformPoint(_corners[0]));
			Vector2 val2 = Vector2.op_Implicit(((Transform)_root).InverseTransformPoint(_corners[2]));
			RectTransform frame = _frame;
			RectTransform frame2 = _frame;
			RectTransform frame3 = _frame;
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(0.5f, 0.5f);
			frame3.pivot = val3;
			Vector2 anchorMin = (frame2.anchorMax = val3);
			frame.anchorMin = anchorMin;
			Vector2 val5 = new Vector2(0.5f, 0.5f) - _root.pivot;
			Rect rect = _root.rect;
			Vector2 val6 = val5 * ((Rect)(ref rect)).size;
			_frame.anchoredPosition = (val + val2) * 0.5f - val6;
			_frame.sizeDelta = val2 - val + new Vector2(6f, 6f);
		}
	}
	public class RoDamageNumbers : MonoBehaviour
	{
		private enum Kind
		{
			Hit,
			Crit,
			Rise
		}

		private readonly struct Style
		{
			public readonly Color Fill;

			public readonly Color Outline;

			public Style(Color fill, Color outline)
			{
				//IL_0001: 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_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				Fill = fill;
				Outline = outline;
			}
		}

		private static class Styles
		{
			public static readonly Style Normal = new Style(Color.white, new Color(0.09f, 0.06f, 0.04f));

			public static readonly Style Weak = new Style(new Color(1f, 0.95f, 0.3f), new Color(0.45f, 0.12f, 0.02f));

			public static readonly Style Resisted = new Style(new Color(0.82f, 0.84f, 0.88f), new Color(0.16f, 0.2f, 0.28f));

			public static readonly Style Immune = new Style(new Color(0.16f, 0.16f, 0.16f), new Color(0.72f, 0.72f, 0.72f));

			public static readonly Style Taken = new Style(new Color(1f, 0.93f, 0.9f), new Color(0.75f, 0.04f, 0.04f));

			public static readonly Style Crit = new Style(new Color(1f, 0.85f, 0.15f), new Color(0.32f, 0.02f, 0f));

			public static readonly Style Heal = new Style(new Color(0.78f, 1f, 0.72f), new Color(0.04f, 0.32f, 0.08f));

			public static readonly Style Miss = new Style(new Color(1f, 0.8f, 0.85f), new Color(0.35f, 0.04f, 0.16f));
		}

		private sealed class Popup
		{
			public RectTransform Rect;

			public CanvasGroup Group;

			public Vector3 World;

			public Kind Kind;

			public float Age;

			public float Duration;

			public float Side;

			public float Scale;
		}

		public const char CritMark = '\u0001';

		private const string Order = "0123456789Mis";

		private const int Cell = 16;

		private const int Height = 14;

		private const int Outline = 2;

		private const float Texel = 2f;

		private const int Max = 150;

		private static RoDamageNumbers _instance;

		private static Dictionary<char, Sprite> _glyphs;

		private static Dictionary<char, Sprite> _outlines;

		private static Sprite _burst;

		internal static bool Handled;

		private readonly List<Popup> _popups = new List<Popup>();

		private Canvas _canvas;

		public static void Destroy()
		{
			if (Object.op_Implicit((Object)(object)_instance))
			{
				Object.Destroy((Object)(object)((Component)_instance).gameObject);
			}
			_instance = null;
		}

		public static bool Show(DamageText owner, TextType type, Vector3 pos, string text, bool mySelf)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			//IL_012d: 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)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Invalid comparison between Unknown and I4
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Invalid comparison between Unknown and I4
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Invalid comparison between Unknown and I4
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Invalid comparison between Unknown and I4
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Invalid comparison between Unknown and I4
			bool flag = text.Length > 0 && text[0] == '\u0001';
			if (flag)
			{
				text = text.Substring(1);
			}
			float scale = 1f;
			Kind kind;
			string shown;
			Style style;
			if (text == "Miss")
			{
				kind = Kind.Rise;
				shown = "Miss";
				style = Styles.Miss;
			}
			else
			{
				if (!float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || ((int)type != 4 && (int)type > 3))
				{
					return false;
				}
				int num = Mathf.RoundToInt(result);
				if (num == 0 && result > 0f)
				{
					num = 1;
				}
				shown = num.ToString(CultureInfo.InvariantCulture);
				kind = Kind.Hit;
				scale = (((int)type == 2) ? 1.2f : (((int)type == 1) ? 0.9f : (((int)type == 3 || num == 0) ? 0.85f : 1f)));
				if ((int)type == 4)
				{
					kind = Kind.Rise;
					style = Styles.Heal;
					scale = 1f;
				}
				else if (num == 0 || (int)type == 3)
				{
					style = Styles.Immune;
				}
				else if (mySelf)
				{
					style = Styles.Taken;
				}
				else if (flag)
				{
					kind = Kind.Crit;
					style = Styles.Crit;
				}
				else
				{
					style = (((int)type == 2) ? Styles.Weak : (((int)type == 1) ? Styles.Resisted : Styles.Normal));
				}
			}
			if (!Ensure())
			{
				return false;
			}
			_instance.Add(kind, pos, shown, style, mySelf, scale);
			return true;
		}

		private static bool Ensure()
		{
			//IL_002f: 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_003a: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)_instance))
			{
				return true;
			}
			if (!LoadSprites())
			{
				return false;
			}
			GameObject val = new GameObject("RO_DamageNumbers", new Type[1] { typeof(RectTransform) });
			Object.DontDestroyOnLoad((Object)val);
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 1;
			CanvasScaler obj = val.AddComponent<CanvasScaler>();
			obj.uiScaleMode = (ScaleMode)1;
			obj.referenceResolution = new Vector2(1920f, 1080f);
			obj.matchWidthOrHeight = 0.5f;
			_instance = val.AddComponent<RoDamageNumbers>();
			_instance._canvas = val2;
			Plugin.Log.LogInfo((object)"RO damage numbers ready");
			return true;
		}

		private static bool LoadSprites()
		{
			//IL_0083: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			if (_glyphs != null)
			{
				return true;
			}
			Texture2D val = Load("damage_digits");
			Texture2D val2 = Load("damage_crit");
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
			{
				return false;
			}
			int[] array = new int[13]
			{
				11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
				13, 6, 10
			};
			_glyphs = new Dictionary<char, Sprite>();
			_outlines = new Dictionary<char, Sprite>();
			for (int i = 0; i < "0123456789Mis".Length; i++)
			{
				_glyphs["0123456789Mis"[i]] = Sprite.Create(val, new Rect((float)(i * 16), 14f, (float)array[i], 14f), new Vector2(0.5f, 0.5f), 100f);
				_outlines["0123456789Mis"[i]] = Sprite.Create(val, new Rect((float)(i * 16), 0f, (float)array[i], 14f), new Vector2(0.5f, 0.5f), 100f);
			}
			_burst = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f);
			return true;
		}

		private static Texture2D Load(string name)
		{
			//IL_005e: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			using Stream stream = typeof(RoDamageNumbers).Assembly.GetManifestResourceStream("Textures/Damage/" + name + ".png");
			if (stream == null)
			{
				Plugin.Log.LogWarning((object)(name + ".png missing: Valheim's damage text stays"));
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				name = "RO_" + name,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)0
			};
			return ImageConversion.LoadImage(val, array) ? val : null;
		}

		private void Add(Kind kind, Vector3 pos, string shown, Style style, bool mySelf, float scale)
		{
			//IL_003e: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			if (_popups.Count >= 150)
			{
				Remove(0);
			}
			GameObject val = new GameObject("RO_Damage", new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasGroup)
			});
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent(((Component)this).transform, false);
			CanvasGroup component = val.GetComponent<CanvasGroup>();
			component.blocksRaycasts = false;
			component.interactable = false;
			float num = 0f;
			string text = shown;
			Rect rect;
			foreach (char key in text)
			{
				float num2 = num;
				rect = _glyphs[key].rect;
				num = num2 + (((Rect)(ref rect)).width - 2f);
			}
			num += 2f;
			if (kind == Kind.Crit)
			{
				float num3 = Mathf.Max(num + 18f, 36.399998f) * 2f;
				Image(val2, _burst, Vector2.zero, new Vector2(num3, num3 * 0.8f), Color.white);
			}
			(Dictionary<char, Sprite>, Color)[] array = new(Dictionary<char, Sprite>, Color)[2]
			{
				(_outlines, style.Outline),
				(_glyphs, style.Fill)
			};
			for (int i = 0; i < array.Length; i++)
			{
				(Dictionary<char, Sprite>, Color) tuple = array[i];
				Dictionary<char, Sprite> item = tuple.Item1;
				Color item2 = tuple.Item2;
				float num4 = (0f - num) / 2f;
				text = shown;
				foreach (char key2 in text)
				{
					rect = item[key2].rect;
					float width = ((Rect)(ref rect)).width;
					Image(val2, item[key2], new Vector2((num4 + width / 2f) * 2f, 0f), new Vector2(width, 14f) * 2f, item2);
					num4 += width - 2f;
				}
			}
			_popups.Add(new Popup
			{
				Rect = val2,
				Group = component,
				World = pos + Random.insideUnitSphere * 0.25f,
				Kind = kind,
				Duration = kind switch
				{
					Kind.Rise => 1.4f, 
					Kind.Crit => 1.5f, 
					_ => 1.3f, 
				},
				Side = (mySelf ? (-1f) : 1f) * Random.Range(0.8f, 1.2f),
				Scale = scale
			});
		}

		private static void Image(RectTransform parent, Sprite sprite, Vector2 at, Vector2 size, Color color)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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)
			GameObject val = new GameObject("Glyph", new Type[1] { typeof(RectTransform) });
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent((Transform)(object)parent, false);
			val2.anchoredPosition = at;
			val2.sizeDelta = size;
			Image obj = val.AddComponent<Image>();
			obj.sprite = sprite;
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = false;
		}

		private void LateUpdate()
		{
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			Camera mainCamera = Utils.GetMainCamera();
			float deltaTime = Time.deltaTime;
			((Behaviour)_canvas).enabled = !Hud.IsUserHidden();
			for (int num = _popups.Count - 1; num >= 0; num--)
			{
				Popup popup = _popups[num];
				popup.Age += deltaTime;
				if (popup.Age >= popup.Duration || !Object.op_Implicit((Object)(object)popup.Rect))
				{
					Remove(num);
				}
				else if (Object.op_Implicit((Object)(object)mainCamera))
				{
					float num2 = popup.Age / popup.Duration;
					Vector3 val;
					float num3;
					if (popup.Kind == Kind.Rise)
					{
						val = Vector3.up * (0.2f + 1.4f * num2);
						num3 = Mathf.Lerp(1.15f, 0.95f, Mathf.Min(1f, num2 * 4f));
					}
					else
					{
						val = ((Component)mainCamera).transform.right * (popup.Side * 1.1f * num2) + Vector3.up * (4.2f * num2 - 6f * num2 * num2);
						num3 = Mathf.Lerp((popup.Kind == Kind.Crit) ? 1.6f : 1.3f, 0.85f, num2);
					}
					Vector3 val2 = Utils.WorldToScreenPointScaled(mainCamera, popup.World + val);
					bool flag = val2.z > 0f && val2.x >= 0f && val2.x <= (float)Screen.width && val2.y >= 0f && val2.y <= (float)Screen.height;
					if (((Component)popup.Rect).gameObject.activeSelf != flag)
					{
						((Component)popup.Rect).gameObject.SetActive(flag);
					}
					if (flag)
					{
						float num4 = Vector3.Distance(((Component)mainCamera).transform.position, popup.World);
						((Transform)popup.Rect).position = val2;
						((Transform)popup.Rect).localScale = Vector3.one * (num3 * popup.Scale * Mathf.Clamp(12f / Mathf.Max(num4, 0.1f), 0.9f, 1.15f));
						popup.Group.alpha = ((num2 < 0.7f) ? 1f : (1f - (num2 - 0.7f) / 0.3f));
					}
				}
			}
		}

		private void Remove(int index)
		{
			if (Object.op_Implicit((Object)(object)_popups[index].Rect))
			{
				Object.Destroy((Object)(object)((Component)_popups[index].Rect).gameObject);
			}
			_popups.RemoveAt(index);
		}
	}
	[HarmonyPatch(typeof(DamageText), "AddInworldText")]
	public static class RoDamageTextPatch
	{
		private static bool Prefix(DamageText __instance, TextType type, Vector3 pos, ref string text, bool mySelf)
		{
			//IL_0034: 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)
			RoDamageNumbers.Handled = false;
			if (!ModConfig.RoDamageNumbers.Value)
			{
				if (text.Length > 0 && text[0] == '\u0001')
				{
					text = text.Substring(1);
				}
				return true;
			}
			RoDamageNumbers.Handled = RoDamageNumbers.Show(__instance, type, pos, text, mySelf);
			if (!RoDamageNumbers.Handled && text.Length > 0 && text[0] == '\u0001')
			{
				text = text.Substring(1);
			}
			return !RoDamageNumbers.Handled;
		}
	}
	[HarmonyPatch(typeof(Character), "ApplyDamage")]
	public static class RoDamageCritPatch
	{
		internal static bool Crit;

		private static void Prefix(Character __instance, bool showDamageText)
		{
			Crit = showDamageText && !__instance.IsPlayer() && (__instance.IsStaggering() || __instance.m_backstabTime == Time.time);
		}

		private static void Finalizer()
		{
			Crit = false;
		}
	}
	[HarmonyPatch(typeof(DamageText), "ShowText", new Type[]
	{
		typeof(TextType),
		typeof(Vector3),
		typeof(string),
		typeof(bool)
	})]
	public static class RoDamageCritMarkPatch
	{
		private static void Prefix(TextType type, ref string text)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if (RoDamageCritPatch.Crit && (int)type <= 3)
			{
				text = "\u0001" + text;
			}
		}
	}
	[HarmonyPatch]
	public static class SeneaLDamageStylePatch
	{
		private static MethodBase _target;

		private static bool Prepare()
		{
			Type type = AccessTools.TypeByName("SeneaLUI.Patches.DamageTextPatch");
			_target = ((type != null) ? AccessTools.Method(type, "Postfix", (Type[])null, (Type[])null) : null);
			return _target != null;
		}

		private static MethodBase TargetMethod()
		{
			return _target;
		}

		private static bool Prefix()
		{
			return !RoDamageNumbers.Handled;
		}
	}
	public class SkillBarHud : MonoBehaviour
	{
		private sealed class Slot
		{
			public Image Background;

			public Image Icon;

			public TextMeshProUGUI Abbrev;

			public TextMeshProUGUI Level;

			public Image Cooldown;

			public TextMeshProUGUI Key;

			public string ShownId;
		}

		private const float SlotSize = 54f;

		private const float Gap = 6f;

		private static SkillBarHud _instance;

		private readonly Slot[] _slots = new Slot[8];

		private TextMeshProUGUI _hint;

		private RectTransform _itemHint;

		private TextMeshProUGUI _itemHintText;

		private HotkeyBar _hotkeyBar;

		private CanvasGroup _group;

		private HudElement _element;

		private static readonly (string glyph, string color)[] Face = new(string, string)[4]
		{
			("Y", "#F5C542"),
			("X", "#4FA3F7"),
			("B", "#F0564B"),
			("A", "#62C556")
		};

		private bool _padKeys;

		public static void Destroy()
		{
			if (Object.op_Implicit((Object)(object)_instance))
			{
				if (Object.op_Implicit((Object)(object)_instance._itemHint))
				{
					Object.Destroy((Object)(object)((Component)_instance._itemHint).gameObject);
				}
				Object.Destroy((Object)(object)((Component)_instance).gameObject);
				_instance = null;
			}
		}

		public static void EnsureCreated()
		{
			//IL_0057: 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)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_instance) && !((Object)(object)Hud.instance == (Object)null) && !((Object)(object)Hud.instance.m_rootObject == (Object)null))
			{
				RectTransform val = UiFactory.Rect("RagnarokJobs_SkillBar", Hud.instance.m_rootObject.transform);
				float num = 474f;
				UiFactory.Place(val, new Vector2(0.5f, 0f), new Vector2(0f, 215f), new Vector2(num, 72f));
				_instance = ((Component)val).gameObject.AddComponent<SkillBarHud>();
				_instance.Build(val);
			}
		}

		private void Build(RectTransform root)
		{
			//IL_0052: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			_group = ((Component)this).gameObject.AddComponent<CanvasGroup>();
			_group.blocksRaycasts = false;
			_group.interactable = false;
			for (int i = 0; i < 8; i++)
			{
				RectTransform val = UiFactory.Place(UiFactory.Rect($"Slot{i + 1}", (Transform)(object)root), new Vector2(0f, 0.5f), new Vector2((float)i * 60f, 0f), new Vector2(54f, 54f));
				Slot slot = new Slot
				{
					Background = UiFactory.Image(val, UiFactory.SlotColor, (ThemePart)2)
				};
				RectTransform val2 = UiFactory.Stretch(UiFactory.Rect("Icon", (Transform)(object)val), 10f);
				slot.Icon = ((Component)val2).gameObject.AddComponent<Image>();
				slot.Icon.preserveAspect = true;
				((Graphic)slot.Icon).raycastTarget = false;
				slot.Abbrev = UiFactory.Text((Transform)(object)val, "Abbrev", 20f, (TextAlignmentOptions)514, UiFactory.TextColor, strong: true);
				RectTransform val3 = UiFactory.Stretch(UiFactory.Rect("Cooldown", (Transform)(object)val), 2f);
				slot.Cooldown = ((Component)val3).gameObject.AddComponent<Image>();
				slot.Cooldown.sprite = UiFactory.White;
				((Graphic)slot.Cooldown).color = new Color(0f, 0f, 0f, 0.65f);
				slot.Cooldown.type = (Type)3;
				slot.Cooldown.fillMethod = (FillMethod)4;
				slot.Cooldown.fillOrigin = 2;
				slot.Cooldown.fillClockwise = false;
				((Graphic)slot.Cooldown).raycastTarget = false;
				TextMeshProUGUI val4 = UiFactory.Text((Transform)(object)val, "Key", 13f, (TextAlignmentOptions)1025, UiFactory.MutedColor, strong: true);
				((TMP_Text)val4).margin = new Vector4(4f, 0f, 0f, 2f);
				((TMP_Text)val4).SetText((i + 1).ToString());
				slot.Key = val4;
				slot.Level = UiFactory.Text((Transform)(object)val, "Level", 12f, (TextAlignmentOptions)260, UiFactory.AccentColor, strong: true);
				((TMP_Text)slot.Level).margin = new Vector4(0f, 2f, 4f, 0f);
				_slots[i] = slot;
			}
			RectTransform val5 = UiFactory.Rect("Hint", (Transform)(object)root);
			Vector2 val6 = default(Vector2);
			((Vector2)(ref val6))..ctor(0f, 0f);
			val5.anchorMax = val6;
			val5.anchorMin = val6;
			val5.pivot = new Vector2(0f, 1f);
			val5.anchoredPosition = new Vector2(0f, 2f);
			val5.sizeDelta = new Vector2(474f, 20f);
			_hint = UiFactory.Text((Transform)(object)val5, "Text", 13f, (TextAlignmentOptions)258, UiFactory.MutedColor);
			((TMP_Text)_hint).textWrappingMode = (TextWrappingModes)0;
			if (Api.Has("hud"))
			{
				_element = HudElements.Add("ragnarokjobs.valheim", "skillbar", "Skill bar (RagnarokJobs)", root);
			}
		}

		private void Update()
		{
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			SeneaLBridge.UpdateExpGauge(localPlayer);
			bool inSkillMode = SkillBar.InSkillMode;
			int shownStack = SkillBar.ShownStack;
			if (SkillWindow.IsOpen)
			{
				_group.alpha = 0f;
				if (Object.op_Implicit((Object)(object)_itemHint))
				{
					((Component)_itemHint).gameObject.SetActive(false);
				}
				return;
			}
			bool active = PadInput.Active;
			_group.alpha = ((inSkillMode || active) ? 1f : 0.45f);
			if (_element != null)
			{
				_element.Busy = inSkillMode;
			}
			UpdateHints(inSkillMode, shownStack, active);
			UpdateKeys(active);
			float acdFraction = SkillCaster.AcdFraction;
			ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon();
			int num = (active ? 4 : 8);
			int num2 = (active ? (SkillBar.PadHalf * 4) : 0);
			for (int i = 0; i < num; i++)
			{
				Slot slot = _slots[i];
				SkillDef skillDef = SkillBar.Get(localPlayer, shownStack, num2 + i);
				int num3 = ((skillDef != null) ? SkillData.EffectiveLevel(localPlayer, skillDef) : 0);
				bool flag = skillDef != null && num3 > 0 && WeaponOk(skillDef, currentWeapon) && HasResources(localPlayer, skillDef, num3);
				Color tint = ((skillDef == null) ? Color.clear : (flag ? UiFactory.TextColor : ((num3 > 0 && !WeaponOk(skillDef, currentWeapon)) ? UiFactory.BadColor : UiFactory.MutedColor)));
				if (slot.ShownId != skillDef?.Id || Time.frameCount % 15 == 0)
				{
					UiFactory.SetIcon(slot.Icon, slot.Abbrev, skillDef, tint);
					slot.ShownId = skillDef?.Id;
				}
				((TMP_Text)slot.Level).SetText((skillDef != null && num3 > 0 && !BuffMacro.IsMacro(skillDef)) ? num3.ToString() : "");
				slot.Cooldown.fillAmount = ((skillDef == null) ? 0f : Mathf.Max(acdFraction, SkillCaster.CooldownFraction(skillDef.Id)));
			}
		}

		private void UpdateKeys(bool pad)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (pad == _padKeys)
			{
				return;
			}
			_padKeys = pad;
			int num = (pad ? 4 : 8);
			float num2 = (float)(8 - num) * 60f / 2f;
			for (int i = 0; i < 8; i++)
			{
				Slot slot = _slots[i];
				RectTransform rectTransform = ((Graphic)slot.Background).rectTransform;
				((Component)rectTransform).gameObject.SetActive(i < num);
				rectTransform.anchoredPosition = new Vector2(num2 + (float)i * 60f, 0f);
				slot.ShownId = "\n";
				if (i < num)
				{
					((TMP_Text)slot.Key).SetText(pad ? ("<color=" + Face[i].color + ">" + Face[i].glyph + "</color>") : (i + 1).ToString());
					((TMP_Text)slot.Key).fontSize = (pad ? 15f : 13f);
				}
			}
		}

		private void UpdateHints(bool skillMode, int stack, bool pad)
		{
			//IL_0010: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			bool value = ModConfig.ShowKeyHints.Value;
			string text = ModConfig.Label(ModConfig.SkillStackKey.Value);
			string text2 = ModConfig.Label(ModConfig.ItemBarKey.Value);
			string text3 = "#" + ColorUtility.ToHtmlStringRGB(UiFactory.AccentColor);
			((Component)_hint).gameObject.SetActive(value);
			if (value && pad)
			{
				int num = SkillBar.PadHalf * 4 + 1;
				((TMP_Text)_hint).SetText($"<color={text3}>Skills {SkillBar.Roman(stack)} {num}-{num + 4 - 1}</color>   LT + Y/X/B/A: cast   " + "<color=" + text3 + ">LT + D-pad</color>: page   LT + RB: dodge   LB + D-pad: zoom   LB + Y: skills");
			}
			else if (value)
			{
				((TMP_Text)_hint).SetText(skillMode ? ("<color=" + text3 + ">Skills " + SkillBar.Roman(stack) + "</color>   1-8: cast   Alt+1-8: items   <color=" + text3 + ">" + text + "</color>: next stack (" + SkillBar.Roman(stack % SkillBar.Stacks + 1) + ")   <color=" + text3 + ">" + text2 + "</color>: items") : ("Alt+1-8: cast Skills " + SkillBar.Roman(stack) + "   <color=" + text3 + ">" + text + "</color>: keys 1-8 for skills"));
			}
			if (!Object.op_Implicit((Object)(object)_hotkeyBar))
			{
				_hotkeyBar = (Object.op_Implicit((Object)(object)Hud.instance) ? ((Component)Hud.instance).GetComponentInChildren<HotkeyBar>(true) : null);
			}
			if (Object.op_Implicit((Object)(object)_hotkeyBar))
			{
				if (!Object.op_Implicit((Object)(object)_itemHint))
				{
					_itemHint = UiFactory.Rect("RagnarokJobs_ItemHint", ((Component)_hotkeyBar).transform);
					_itemHint.pivot = new Vector2(0f, 1f);
					_itemHint.sizeDelta = new Vector2(8f * _hotkeyBar.m_elementSpace, 20f);
					_itemHintText =