Decompiled source of Ironbound v0.5.7

BepInEx/plugins/Ironbound/Ironbound.dll

Decompiled 6 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Ironbound.Configuration;
using Ironbound.Features.Equipment;
using Ironbound.Features.Gameplay;
using Ironbound.Features.Mounts;
using Ironbound.Features.NearbyStorage;
using Ironbound.Features.QualityOfLife;
using Ironbound.HUD;
using Ironbound.Networking;
using Ironbound.UI;
using Ironbound.UI.Windows;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.TextCore.LowLevel;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("KernelPanic")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Ironbound: a custom Valheim experience for friends.")]
[assembly: AssemblyFileVersion("0.5.7.0")]
[assembly: AssemblyInformationalVersion("0.5.7-alpha+1f6487fc59ca713439087cda48806239688cc780")]
[assembly: AssemblyProduct("Ironbound")]
[assembly: AssemblyTitle("Ironbound")]
[assembly: AssemblyVersion("0.5.7.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 Ironbound
{
	[BepInPlugin("com.kernelpanic.ironbound", "Ironbound", "0.5.7")]
	[BepInIncompatibility("com.kernelpanic.ragnarok")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency("com.jotunn.jotunn", "2.30.2")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.kernelpanic.ironbound";

		public const string PluginName = "Ironbound";

		public const string PluginVersion = "0.5.7";

		private Harmony? harmony;

		private JotunnIntegration? jotunn;

		private UiLocalization? localization;

		private ContainerRegistry? containers;

		private InterfaceSettings ui;

		private ConfigWindow? window;

		private Theme? theme;

		private IronboundHud? hud;

		private InventoryPanel? inventoryPanel;

		private InfoPanel? infoPanel;

		private InventoryScale? inventoryScale;

		private ChestPanel? chestPanel;

		private HoverPrompt? hoverPrompt;

		private CrosshairAmmo? crosshairAmmo;

		private MountHudLayout? mountHud;

		private CombatIndicator? combatIndicator;

		private ChestHoverPreview? chestHoverPreview;

		private IronboundActionBar? actionBar;

		private BuildTaskPanel? buildTask;

		private BuildMenuPanel? buildMenu;

		private ChestSearch? chestSearch;

		private WeaponDial? weaponDial;

		private VanillaQuickStack? vanillaQuickStack;

		private VanillaChestSort? vanillaChestSort;

		private VanillaCharacterPanel? vanillaCharacter;

		private MinimapInfo? minimapInfo;

		private MinimapSkin? minimapSkin;

		private LargeMapLayer? largeMapLayer;

		private TamedAnimalMarkers? tamedAnimals;

		private NotificationFeed? notifications;

		private PopupCommands? popupCommands;

		private Compendium? compendium;

		private SkillsBook? skillsBook;

		private TrophiesBook? trophiesBook;

		private AchievementsBook? achievementsBook;

		private CraftPanel? craftPanel;

		private VanillaCraftFilter? vanillaCraftFilter;

		private VanillaProvisionBar? vanillaProvisions;

		private CompassStrip? compass;

		private ServerConfig? serverConfig;

		private MountService? mounts;

		private MountClient? mountClient;

		private StationModifiers? stationModifiers;

		private ConfigEntry<bool> showBadge;

		private ConfigEntry<string> badgeText;

		private ConfigEntry<KeyboardShortcut> reloadConfigKey;

		private ConfigEntry<KeyboardShortcut> toggleBadgeKey;

		private bool disposed;

		private void Awake()
		{
			bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			try
			{
				ConfigMigration.Upgrade(((BaseUnityPlugin)this).Config);
				Initialize();
				((BaseUnityPlugin)this).Config.Save();
			}
			catch
			{
				((Behaviour)this).enabled = false;
				OnDestroy();
				throw;
			}
			finally
			{
				((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet;
			}
		}

		private void Initialize()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Invalid comparison between Unknown and I4
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Expected O, but got Unknown
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			JotunnIntegration.Require();
			showBadge = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD.Development", "ShowBadge", false, "Show the development status badge. F8 toggles it.");
			badgeText = ((BaseUnityPlugin)this).Config.Bind<string>("HUD.Development", "BadgeText", "Ironbound loaded", "Text shown in the badge. Edit this file and press F7 to test live configuration.");
			reloadConfigKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("HUD.Development", "ReloadConfigKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Reload this plugin's configuration.");
			toggleBadgeKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("HUD.Development", "ToggleBadgeKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Toggle the development status badge.");
			ui = new InterfaceSettings(((BaseUnityPlugin)this).Config);
			CharacterSlots.Enabled = () => ui.Features.CharacterSlots.Value;
			CharacterSlots.ExtraUtilityEnabled = () => ui.Features.ExtraUtilitySlots.Value;
			ProvisionKeys.Keys = ui.Features.ProvisionKeys;
			PlantHoverStatus.Enabled = () => ui.Features.PlantStatus.Value;
			GameplaySettings gameplaySettings = (GameplaySettings.Current = new GameplaySettings(((BaseUnityPlugin)this).Config));
			SailingAndTurrets sailingAndTurrets = (SailingAndTurrets.Current = new SailingAndTurrets(((BaseUnityPlugin)this).Config));
			stationModifiers = new StationModifiers(((BaseUnityPlugin)this).Config);
			StationModifiers.Current = stationModifiers;
			TombstoneRecovery.Enabled = () => ui.Features.AutoEquipOnReclaim.Value;
			BetterArcheryQuiverSlotsPatch.ShownByIronbound = () => InventoryPanel.LayoutOf(ui) > 0;
			StorageRuntime.Settings = new StorageSettings(((BaseUnityPlugin)this).Config);
			containers = new ContainerRegistry(StorageRuntime.Settings);
			StorageRuntime.Registry = containers;
			mounts = new MountService(new MountSettings(((BaseUnityPlugin)this).Config), ((BaseUnityPlugin)this).Logger);
			serverConfig = new ServerConfig(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger, "0.5.7", ((IEnumerable<ConfigEntryBase>)(object)new ConfigEntryBase[14]
			{
				(ConfigEntryBase)StorageRuntime.Settings.Enabled,
				(ConfigEntryBase)StorageRuntime.Settings.Range,
				(ConfigEntryBase)ui.Features.CharacterSlots,
				(ConfigEntryBase)ui.Features.ExtraUtilitySlots,
				(ConfigEntryBase)ui.Features.AutoEquipOnReclaim,
				(ConfigEntryBase)gameplaySettings.PowerDuration,
				(ConfigEntryBase)gameplaySettings.PowerCooldown,
				(ConfigEntryBase)gameplaySettings.HarvestMultiplier,
				(ConfigEntryBase)gameplaySettings.SkillLossModifier,
				(ConfigEntryBase)gameplaySettings.SkillXpModifier,
				(ConfigEntryBase)gameplaySettings.RunCost,
				(ConfigEntryBase)gameplaySettings.AttackCost,
				(ConfigEntryBase)gameplaySettings.JumpCost,
				(ConfigEntryBase)gameplaySettings.EitrCost
			}).Concat(stationModifiers.Synced).Concat(sailingAndTurrets.Synced).Concat(mounts.Settings.Synced), ((IEnumerable<ConfigEntryBase>)(object)new ConfigEntryBase[3]
			{
				(ConfigEntryBase)StorageRuntime.Settings.Enabled,
				(ConfigEntryBase)StorageRuntime.Settings.Range,
				(ConfigEntryBase)ui.Features.AutoEquipOnReclaim
			}).Concat(mounts.Settings.Synced));
			if ((int)SystemInfo.graphicsDeviceType != 4)
			{
				BuildInterface();
			}
			harmony = new Harmony("com.kernelpanic.ironbound." + Guid.NewGuid().ToString("N"));
			harmony.PatchAll(typeof(Plugin).Assembly);
			containers.Initialize();
			stationModifiers.Initialize();
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("Ironbound {0} loaded. {1}: settings; HUD: {2}; nearby chests range {3}m.", "0.5.7", ui.WindowKey.Value, ui.Hud.Value, StorageRuntime.Settings.Range.Value));
		}

		private void BuildInterface()
		{
			localization = new UiLocalization(((BaseUnityPlugin)this).Info.Metadata);
			jotunn = JotunnIntegration.Create(((BaseUnityPlugin)this).Logger);
			mountClient = new MountClient(mounts, jotunn);
			theme = new Theme();
			hud = new IronboundHud(ui, theme);
			inventoryPanel = new InventoryPanel(ui, theme);
			inventoryScale = new InventoryScale(ui, () => inventoryPanel.Wanted);
			chestPanel = new ChestPanel(ui, theme, () => inventoryPanel.Wanted, () => inventoryPanel.SlotSize);
			hoverPrompt = new HoverPrompt(ui, theme);
			crosshairAmmo = new CrosshairAmmo(ui, theme);
			mountHud = new MountHudLayout(ui, theme);
			combatIndicator = new CombatIndicator(ui, theme);
			chestHoverPreview = new ChestHoverPreview(ui, theme);
			actionBar = new IronboundActionBar(ui, theme);
			buildTask = new BuildTaskPanel(ui, theme);
			buildMenu = new BuildMenuPanel(ui, theme);
			chestSearch = new ChestSearch(ui, theme);
			weaponDial = new WeaponDial(ui, theme, jotunn);
			infoPanel = new InfoPanel(ui, theme, () => inventoryPanel.Wanted);
			vanillaQuickStack = new VanillaQuickStack(ui, theme, inventoryPanel);
			vanillaChestSort = new VanillaChestSort(theme, () => inventoryPanel.Wanted);
			vanillaCharacter = new VanillaCharacterPanel(ui, theme, inventoryPanel);
			minimapInfo = new MinimapInfo(ui, theme);
			minimapSkin = new MinimapSkin(ui, theme);
			largeMapLayer = new LargeMapLayer();
			tamedAnimals = new TamedAnimalMarkers(ui);
			notifications = new NotificationFeed(ui, theme);
			popupCommands = new PopupCommands(notifications);
			compendium = new Compendium(ui, theme);
			skillsBook = new SkillsBook(ui, theme);
			trophiesBook = new TrophiesBook(ui, theme);
			achievementsBook = new AchievementsBook(ui, theme);
			craftPanel = new CraftPanel(ui, theme);
			vanillaCraftFilter = new VanillaCraftFilter(ui, theme, () => craftPanel.Wanted);
			hud.KeysDock = () => craftPanel.Shown;
			vanillaProvisions = new VanillaProvisionBar(ui, () => hud.Active);
			CraftFilter.Enabled = () => craftPanel.Wanted || ui.Features.CraftFilters.Value;
			CraftFilter.SortEnabled = () => craftPanel.Wanted || ui.Features.CraftFilters.Value;
			Theme.ChipEdges = () => ui.Edges.Value == FrameEdges.Chipped;
			Ugui.ScrollRows = () => (ui.FollowSystemScroll.Value ? SystemScroll.Lines() : ((float?)null)) ?? ui.ScrollSpeed.Value;
			compass = new CompassStrip(ui, theme);
			window = new ConfigWindow(((BaseUnityPlugin)this).Config, ui, theme, "0.5.7", ChestsInRange, jotunn);
			if (jotunn != null)
			{
				jotunn.GuiRecreated = delegate
				{
					window?.SetOpen(open: false);
				};
			}
			window.AddAction("HUD.Notifications", "Test notifications", "Sends a sample unlock and two small messages through Valheim, so they show in the style that is on. In a world only.", NotificationFeed.Test);
			window.AddAction("QualityOfLife.Mounts", "Release mount bond", "Release your bond without approaching the mount. Its saddle and position are preserved.", delegate
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				mounts?.Send(2, ZDOID.None);
			});
			window.AddStatus("QualityOfLife.Mounts", () => (!mounts.Available) ? "Waiting for a Ironbound mount server, or enter a local world." : mounts.CompanionSummary);
			VanillaHudPatch.HideVanilla = () => hud.Active;
			VanillaHudPatch.HideStatus = () => hud.Active && ui.HudStatus.Value;
			VanillaHudPatch.HidePower = () => hud.Active && ui.HudPower.Value;
			VanillaHudPatch.HideKeys = () => hud.Active && ui.HudKeys.Value;
		}

		private void Update()
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			serverConfig?.Tick();
			mounts?.Tick();
			mountClient?.Tick();
			stationModifiers?.Tick();
			window?.Update();
			chestSearch?.Update();
			weaponDial?.Update();
			jotunn?.Tick();
			if (UiState.WindowOpen)
			{
				return;
			}
			KeyboardShortcut value = reloadConfigKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				try
				{
					((BaseUnityPlugin)this).Config.Reload();
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Ironbound configuration reloaded.");
				}
				catch (Exception arg)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)$"Could not reload configuration: {arg}");
				}
			}
			ProvisionKeys.Update();
			value = toggleBadgeKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				showBadge.Value = !showBadge.Value;
			}
		}

		private void OnGUI()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (showBadge.Value && !UiState.WindowOpen)
			{
				GUI.Box(new Rect(16f, 16f, 340f, 54f), string.Format("{0}\nv{1} | {2} settings | F6 code | F7 config", badgeText.Value, "0.5.7", ui.WindowKey.Value));
			}
		}

		private void LateUpdate()
		{
			mountClient?.LateUpdate();
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				if (CharacterSlots.Enabled())
				{
					CharacterSlots.Settle(Player.m_localPlayer, Object.op_Implicit((Object)(object)InventoryGui.instance) ? SlotActions.DragItem.Invoke(InventoryGui.instance) : null);
				}
				else
				{
					CharacterSlots.Empty(((Humanoid)Player.m_localPlayer).GetInventory());
				}
				CharacterSlots.SyncEffects(Player.m_localPlayer);
			}
			chestSearch?.LateUpdate();
			actionBar?.Tick();
			hoverPrompt?.Tick();
			crosshairAmmo?.Tick();
			chestHoverPreview?.Tick();
			TombstoneRecovery.Tick();
			combatIndicator?.Tick();
			hud?.Tick();
			buildTask?.Tick();
			buildMenu?.Tick();
			InventoryPanel? obj = inventoryPanel;
			if (obj != null && obj.Wanted)
			{
				vanillaQuickStack?.Dispose();
				vanillaChestSort?.Dispose();
				vanillaCharacter?.Dispose();
			}
			inventoryPanel?.Tick();
			infoPanel?.Tick();
			chestPanel?.Tick();
			vanillaQuickStack?.Tick();
			vanillaChestSort?.Tick();
			vanillaCharacter?.Tick();
			inventoryScale?.Tick();
			minimapInfo?.Tick();
			minimapSkin?.Tick();
			largeMapLayer?.Tick();
			tamedAnimals?.Tick();
			notifications?.Tick();
			popupCommands?.Tick();
			compendium?.Tick();
			skillsBook?.Tick();
			trophiesBook?.Tick();
			achievementsBook?.Tick();
			craftPanel?.Tick();
			vanillaCraftFilter?.Tick();
			vanillaProvisions?.Tick();
			compass?.Tick();
			mountHud?.Tick();
			jotunn?.Tick();
		}

		private static string ChestsInRange()
		{
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer) || StorageRuntime.Registry == null)
			{
				return "—";
			}
			return StorageRuntime.Registry.Nearby(localPlayer).Count.ToString();
		}

		private void OnDestroy()
		{
			if (disposed)
			{
				return;
			}
			disposed = true;
			UiState.Reset();
			WeaponDial.Open = false;
			Release("input integration", delegate
			{
				jotunn?.Dispose();
			});
			Release("patches", delegate
			{
				Harmony? obj = harmony;
				if (obj != null)
				{
					obj.UnpatchSelf();
				}
			});
			Release("coroutines", ((MonoBehaviour)this).StopAllCoroutines);
			Release("mount controls", delegate
			{
				mountClient?.Dispose();
			});
			Release("mount service", delegate
			{
				mounts?.Dispose();
			});
			Release("chestSearch", delegate
			{
				chestSearch?.Dispose();
			});
			Release("weaponDial", delegate
			{
				weaponDial?.Dispose();
			});
			PlantHoverStatus.Enabled = () => false;
			Release("actionBar", delegate
			{
				actionBar?.Dispose();
			});
			Release("buildTask", delegate
			{
				buildTask?.Dispose();
			});
			Release("buildMenu", delegate
			{
				buildMenu?.Dispose();
			});
			Release("hoverPrompt", delegate
			{
				hoverPrompt?.Dispose();
			});
			Release("crosshairAmmo", delegate
			{
				crosshairAmmo?.Dispose();
			});
			Release("mount HUD layout", delegate
			{
				mountHud?.Dispose();
			});
			Release("combat indicator", delegate
			{
				combatIndicator?.Dispose();
			});
			Release("chestHoverPreview", delegate
			{
				chestHoverPreview?.Dispose();
			});
			SailingAndTurrets.Current = null;
			Release("turret markers", delegate
			{
				Turret[] array = Object.FindObjectsByType<Turret>((FindObjectsSortMode)0);
				foreach (Turret val in array)
				{
					if (Object.op_Implicit((Object)(object)val.m_marker))
					{
						val.m_marker.m_radius = val.m_viewDistance;
					}
				}
			});
			Release("stationModifiers", delegate
			{
				stationModifiers?.Dispose();
			});
			GameplaySettings.Current = null;
			Release("Equipment.TombstoneRecovery.Reset", delegate
			{
				TombstoneRecovery.Reset();
			});
			Release("serverConfig", delegate
			{
				serverConfig?.Dispose();
			});
			Release("containers", delegate
			{
				containers?.Dispose();
			});
			Release("VanillaHudPatch.Restore", delegate
			{
				VanillaHudPatch.Restore();
			});
			VanillaHudPatch.HideVanilla = () => false;
			VanillaHudPatch.HideStatus = () => false;
			VanillaHudPatch.HidePower = () => false;
			VanillaHudPatch.HideKeys = () => false;
			CharacterSlots.Enabled = () => false;
			CharacterSlots.ExtraUtilityEnabled = () => false;
			Release("Equipment.CharacterSlots.ClearEffects", delegate
			{
				CharacterSlots.ClearEffects();
			});
			UiState.Reset();
			Release("window", delegate
			{
				window?.Dispose();
			});
			Release("vanillaQuickStack", delegate
			{
				vanillaQuickStack?.Dispose();
			});
			Release("vanillaChestSort", delegate
			{
				vanillaChestSort?.Dispose();
			});
			Release("vanillaCharacter", delegate
			{
				vanillaCharacter?.Dispose();
			});
			Release("minimapInfo", delegate
			{
				minimapInfo?.Dispose();
			});
			Release("minimapSkin", delegate
			{
				minimapSkin?.Dispose();
			});
			Release("largeMapLayer", delegate
			{
				largeMapLayer?.Dispose();
			});
			Release("tamedAnimals", delegate
			{
				tamedAnimals?.Dispose();
			});
			Release("popupCommands", delegate
			{
				popupCommands?.Dispose();
			});
			Release("notifications", delegate
			{
				notifications?.Dispose();
			});
			Release("compendium", delegate
			{
				compendium?.Dispose();
			});
			Release("skillsBook", delegate
			{
				skillsBook?.Dispose();
			});
			Release("trophiesBook", delegate
			{
				trophiesBook?.Dispose();
			});
			Release("achievementsBook", delegate
			{
				achievementsBook?.Dispose();
			});
			Release("craftPanel", delegate
			{
				craftPanel?.Dispose();
			});
			Release("vanillaCraftFilter", delegate
			{
				vanillaCraftFilter?.Dispose();
			});
			Release("CraftAmount.Unload", delegate
			{
				CraftAmount.Unload();
			});
			Release("vanillaProvisions", delegate
			{
				vanillaProvisions?.Dispose();
			});
			CraftFilter.Enabled = () => false;
			CraftFilter.SortEnabled = () => false;
			Release("CraftFilter.Reset", delegate
			{
				CraftFilter.Reset();
			});
			Release("crafting refresh", delegate
			{
				if (Object.op_Implicit((Object)(object)InventoryGui.instance) && Object.op_Implicit((Object)(object)Player.m_localPlayer) && InventoryGui.IsVisible())
				{
					CraftFilter.Changed();
				}
			});
			NotificationFeed.Instance = null;
			Release("compass", delegate
			{
				compass?.Dispose();
			});
			Release("infoPanel", delegate
			{
				infoPanel?.Dispose();
			});
			Release("chestPanel", delegate
			{
				chestPanel?.Dispose();
			});
			Release("inventoryScale", delegate
			{
				inventoryScale?.Dispose();
			});
			Release("inventoryPanel", delegate
			{
				inventoryPanel?.Dispose();
			});
			Release("hud", delegate
			{
				hud?.Dispose();
			});
			Release("theme", delegate
			{
				theme?.Dispose();
			});
			Release("localization", delegate
			{
				localization?.Dispose();
			});
			Ironbound.Features.NearbyStorage.ResourceScope.Current = null;
			Release("CraftingChestGate.Reset", delegate
			{
				CraftingChestGate.Reset();
			});
			StorageRuntime.Registry = null;
			ProvisionKeys.Keys = Array.Empty<ConfigEntry<KeyboardShortcut>>();
			BetterArcheryQuiverSlotsPatch.ShownByIronbound = () => false;
			Release("Features.QualityOfLife.ItemTrash.Reset", delegate
			{
				ItemTrash.Reset();
			});
			Theme.ChipEdges = () => false;
			Ugui.ScrollRows = () => 3f;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Ironbound unloaded.");
			void Release(string name, Action release)
			{
				UiLifetime.Cleanup(release, delegate(Exception exception)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)$"Ironbound cleanup failed ({name}): {exception}");
				});
			}
		}
	}
}
namespace Ironbound.UI
{
	internal static class BuildMenuRules
	{
		internal static (int First, int Count) Window(int total, int columns, int rows, float offset, float rowStride)
		{
			if (total <= 0)
			{
				return (First: 0, Count: 0);
			}
			columns = Math.Max(1, columns);
			rows = Math.Max(1, rows);
			int num = (total + columns - 1) / columns;
			int num2 = Math.Min((rowStride > 0f) ? ((int)Math.Floor(Math.Max(0f, offset) / rowStride)) : 0, Math.Max(0, num - rows)) * columns;
			return (First: num2, Count: Math.Min(total - num2, (rows + 1) * columns));
		}
	}
	internal sealed class CapsuleGraphic : MaskableGraphic
	{
		internal static CapsuleGraphic Create(Transform parent, string name, Color color)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			CapsuleGraphic capsuleGraphic = ((Component)Ugui.Node(parent, name)).gameObject.AddComponent<CapsuleGraphic>();
			((Graphic)capsuleGraphic).color = color;
			((Graphic)capsuleGraphic).raycastTarget = false;
			return capsuleGraphic;
		}

		protected override void OnPopulateMesh(VertexHelper mesh)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			mesh.Clear();
			Rect pixelAdjustedRect = ((Graphic)this).GetPixelAdjustedRect();
			if (!(((Rect)(ref pixelAdjustedRect)).width <= 0f) && !(((Rect)(ref pixelAdjustedRect)).height <= 0f))
			{
				float num = Mathf.Min(((Rect)(ref pixelAdjustedRect)).width, ((Rect)(ref pixelAdjustedRect)).height) / 2f;
				float num2 = Mathf.Max(0f, num - 0.6f);
				Vector2 center = ((Rect)(ref pixelAdjustedRect)).center;
				mesh.AddVert(Vector2.op_Implicit(center), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero));
				Color color = ((Graphic)this).color;
				color.a = 0f;
				Vector2 val = default(Vector2);
				Vector2 val2 = default(Vector2);
				for (int i = 0; i < 26; i++)
				{
					bool flag = i <= 12;
					float num3 = (flag ? (-90f + (float)i * 180f / 12f) : (90f + (float)(i - 12 - 1) * 180f / 12f)) * ((float)Math.PI / 180f);
					((Vector2)(ref val))..ctor(Mathf.Cos(num3), Mathf.Sin(num3));
					((Vector2)(ref val2))..ctor(flag ? (((Rect)(ref pixelAdjustedRect)).xMax - num) : (((Rect)(ref pixelAdjustedRect)).xMin + num), center.y);
					mesh.AddVert(Vector2.op_Implicit(val2 + val * num2), Color32.op_Implicit(((Graphic)this).color), Vector4.op_Implicit(Vector2.zero));
					mesh.AddVert(Vector2.op_Implicit(val2 + val * num), Color32.op_Implicit(color), Vector4.op_Implicit(Vector2.zero));
				}
				for (int j = 0; j < 26; j++)
				{
					int num4 = 1 + j * 2;
					int num5 = 1 + (j + 1) % 26 * 2;
					mesh.AddTriangle(0, num4, num5);
					mesh.AddTriangle(num4, num4 + 1, num5 + 1);
					mesh.AddTriangle(num4, num5 + 1, num5);
				}
			}
		}
	}
	internal sealed class CraftFrameGraphic : MaskableGraphic, ICanvasRaycastFilter
	{
		private float wingWidth;

		private float wingTop;

		private float wingHeight;

		private bool wing;

		private bool border;

		private const float Stroke = 0.8f;

		private const float Fringe = 0.6f;

		private const float Row = 0.75f;

		internal static CraftFrameGraphic Create(Transform parent, string name, float wingWidth, float wingTop, float wingHeight, bool border, Color color)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			CraftFrameGraphic craftFrameGraphic = ((Component)Ugui.Node(parent, name)).gameObject.AddComponent<CraftFrameGraphic>();
			craftFrameGraphic.wingWidth = wingWidth;
			craftFrameGraphic.wingTop = wingTop;
			craftFrameGraphic.wingHeight = wingHeight;
			craftFrameGraphic.border = border;
			((Graphic)craftFrameGraphic).color = color;
			((Graphic)craftFrameGraphic).raycastTarget = !border;
			craftFrameGraphic.Stretch<CraftFrameGraphic>(0f - wingWidth, 0f, 0f, 0f);
			return craftFrameGraphic;
		}

		internal void ShowWing(bool visible)
		{
			if (wing != visible)
			{
				wing = visible;
				((Graphic)this).SetVerticesDirty();
			}
		}

		protected override void OnPopulateMesh(VertexHelper mesh)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			mesh.Clear();
			Rect rect = ((Graphic)this).rectTransform.rect;
			float num = ((Rect)(ref rect)).width - wingWidth;
			float height = ((Rect)(ref rect)).height;
			if (num <= 0f || height <= 0f)
			{
				return;
			}
			float num2 = ((Rect)(ref rect)).xMin + wingWidth;
			float num3 = Mathf.Max(0.75f, height / 1600f);
			for (float num4 = 0f; num4 < height; num4 += num3)
			{
				float num5 = Mathf.Min(num4 + num3, height);
				float y = (num4 + num5) / 2f;
				if (CraftFrameShape.Bounds(num, height, wingWidth, wingTop, wingHeight, wing, y, 0f, out var left, out var right))
				{
					if (!border || !CraftFrameShape.Bounds(num, height, wingWidth, wingTop, wingHeight, wing, y, 0.8f, out var left2, out var right2))
					{
						Band(mesh, num2 + left, num2 + right, ((Rect)(ref rect)).yMax - num4, ((Rect)(ref rect)).yMax - num5);
						continue;
					}
					Band(mesh, num2 + left, num2 + left2, ((Rect)(ref rect)).yMax - num4, ((Rect)(ref rect)).yMax - num5);
					Band(mesh, num2 + right2, num2 + right, ((Rect)(ref rect)).yMax - num4, ((Rect)(ref rect)).yMax - num5);
				}
			}
		}

		private void Band(VertexHelper mesh, float left, float right, float top, float bottom)
		{
			//IL_001a: 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)
			//IL_0033: 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)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (!(right <= left))
			{
				float num = Mathf.Min(0.6f, (right - left) / 3f);
				Color val = ((Graphic)this).color.WithAlpha(0f);
				Quad(mesh, left, left + num, top, bottom, val, ((Graphic)this).color);
				Quad(mesh, left + num, right - num, top, bottom, ((Graphic)this).color, ((Graphic)this).color);
				Quad(mesh, right - num, right, top, bottom, ((Graphic)this).color, val);
			}
		}

		private static void Quad(VertexHelper mesh, float left, float right, float top, float bottom, Color a, Color b)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//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_0039: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_006b: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			int currentVertCount = mesh.currentVertCount;
			mesh.AddVert(new Vector3(left, top), Color32.op_Implicit(a), Vector4.op_Implicit(Vector2.zero));
			mesh.AddVert(new Vector3(right, top), Color32.op_Implicit(b), Vector4.op_Implicit(Vector2.zero));
			mesh.AddVert(new Vector3(right, bottom), Color32.op_Implicit(b), Vector4.op_Implicit(Vector2.zero));
			mesh.AddVert(new Vector3(left, bottom), Color32.op_Implicit(a), Vector4.op_Implicit(Vector2.zero));
			mesh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
			mesh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3);
		}

		public bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(((Graphic)this).rectTransform, screenPoint, eventCamera, ref val))
			{
				return false;
			}
			Rect rect = ((Graphic)this).rectTransform.rect;
			float num = val.x - ((Rect)(ref rect)).xMin - wingWidth;
			float y = ((Rect)(ref rect)).yMax - val.y;
			if (CraftFrameShape.Bounds(((Rect)(ref rect)).width - wingWidth, ((Rect)(ref rect)).height, wingWidth, wingTop, wingHeight, wing, y, 0f, out var left, out var right) && num >= left)
			{
				return num <= right;
			}
			return false;
		}
	}
	internal static class CraftFrameShape
	{
		internal static bool Bounds(float width, float height, float wingWidth, float wingTop, float wingHeight, bool wing, float y, float inset, out float left, out float right)
		{
			left = (right = 0f);
			if (width <= inset * 2f || height <= inset * 2f || y < inset || y > height - inset)
			{
				return false;
			}
			float radius = Math.Max(0f, Math.Min(12f, Math.Min(width, height) / 2f) - inset);
			float num = Corner(y - inset, height - inset * 2f, radius);
			left = inset + num;
			right = width - inset - num;
			if (wing && wingWidth > inset && wingHeight > inset * 2f && y >= wingTop + inset && y <= wingTop + wingHeight - inset)
			{
				float radius2 = Math.Max(0f, Math.Min(8f, wingHeight / 2f) - inset);
				float val = 0f - wingWidth + inset + Corner(y - wingTop - inset, wingHeight - inset * 2f, radius2);
				left = Math.Min(left, val);
			}
			return right > left;
		}

		private static float Corner(float y, float height, float radius)
		{
			float num = Math.Min(y, height - y);
			if (num >= radius || radius <= 0f)
			{
				return 0f;
			}
			float num2 = radius - Math.Max(0f, num);
			return radius - (float)Math.Sqrt(Math.Max(0f, radius * radius - num2 * num2));
		}
	}
	internal static class FontLibrary
	{
		private const string Common = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§\u00a8©ª«¬®\u00af°±²³\u00b4µ¶·\u00b8¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĞğİıŞşŁłŒœŠšŽžŸ–—‘’‚“”„†‡•…‰‹›€™→←↑↓";

		private static readonly Dictionary<string, TMP_FontAsset?> loaded = new Dictionary<string, TMP_FontAsset>();

		internal static TMP_FontAsset? Get(string file, string? extended = null)
		{
			if (loaded.TryGetValue(file, out TMP_FontAsset value))
			{
				return value;
			}
			TMP_FontAsset val = Create(file);
			if (Object.op_Implicit((Object)(object)val) && extended != null)
			{
				TMP_FontAsset val2 = Create(extended);
				if (val2 != null)
				{
					val.fallbackFontAssetTable = new List<TMP_FontAsset> { val2 };
				}
			}
			loaded[file] = val;
			return val;
		}

		internal static void Dispose()
		{
			HashSet<Object> owned = new HashSet<Object>();
			foreach (TMP_FontAsset value in loaded.Values)
			{
				Collect(value);
			}
			foreach (Object item in owned)
			{
				Object.Destroy(item);
			}
			loaded.Clear();
			void Collect(TMP_FontAsset? asset)
			{
				if (Object.op_Implicit((Object)(object)asset) && owned.Add((Object)(object)asset))
				{
					if (Object.op_Implicit((Object)(object)((TMP_Asset)asset).material))
					{
						owned.Add((Object)(object)((TMP_Asset)asset).material);
					}
					Texture2D[] atlasTextures = asset.atlasTextures;
					foreach (Texture2D val in atlasTextures)
					{
						if (Object.op_Implicit((Object)(object)val))
						{
							owned.Add((Object)(object)val);
						}
					}
					if (asset.fallbackFontAssetTable != null)
					{
						foreach (TMP_FontAsset item2 in asset.fallbackFontAssetTable)
						{
							Collect(item2);
						}
					}
				}
			}
		}

		private static TMP_FontAsset? Create(string file)
		{
			try
			{
				string text = Extract(file);
				if (text == null)
				{
					return null;
				}
				TMP_FontAsset val = TMP_FontAsset.CreateFontAsset(text, 0, 64, 7, (GlyphRenderMode)4165, 1024, 1024);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Debug.LogWarning((object)("[Ironbound] Could not load font " + file + "."));
					return null;
				}
				((Object)val).name = "Ironbound " + Path.GetFileNameWithoutExtension(file);
				string text2 = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§\u00a8©ª«¬®\u00af°±²³\u00b4µ¶·\u00b8¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿĞğİıŞşŁłŒœŠšŽžŸ–—‘’‚“”„†‡•…‰‹›€™→←↑↓";
				if (file == "NotoSansRunic-Regular.ttf")
				{
					text2 = "";
					for (char c = 'ᚠ'; c <= 'ᛸ'; c = (char)(c + 1))
					{
						text2 += c;
					}
				}
				string text3 = default(string);
				val.TryAddCharacters(text2, ref text3, false);
				Debug.Log((object)("[Ironbound] Font " + ((Object)val).name + " loaded" + ((text3.Length > 0) ? $" ({text3.Length} characters not in this file)." : ".")));
				return val;
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[Ironbound] Could not load font " + file + ": " + ex.Message));
				return null;
			}
		}

		private static string? Extract(string file)
		{
			using Stream stream = typeof(FontLibrary).Assembly.GetManifestResourceStream("Ironbound.Fonts." + file);
			if (stream == null)
			{
				return null;
			}
			string text = Path.Combine(Paths.CachePath, "Ironbound", "Fonts");
			Directory.CreateDirectory(text);
			string text2 = Path.Combine(text, file);
			if (File.Exists(text2) && new FileInfo(text2).Length == stream.Length)
			{
				return text2;
			}
			using FileStream destination = File.Create(text2);
			stream.CopyTo(destination);
			return text2;
		}
	}
	internal sealed class JotunnIntegration : IDisposable
	{
		internal sealed class Binding : IDisposable
		{
			private readonly JotunnIntegration owner;

			private readonly string shortName;

			private readonly ConfigEntry<KeyboardShortcut>? key;

			private readonly ConfigEntry<GamepadButton>? gamepad;

			private ButtonConfig? config;

			private bool disposed;

			internal readonly bool SettingsToggle;

			internal string Name => shortName + "!com.kernelpanic.ironbound";

			internal bool Registered => config != null;

			internal bool Down
			{
				get
				{
					//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_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
					if (!Registered)
					{
						if (key != null)
						{
							KeyboardShortcut value = key.Value;
							if ((int)((KeyboardShortcut)(ref value)).MainKey != 0)
							{
								value = key.Value;
								return Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey);
							}
						}
						return false;
					}
					if (ZInput.instance != null)
					{
						return ZInput.GetButtonDown(Name);
					}
					return false;
				}
			}

			internal bool Held
			{
				get
				{
					//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_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
					if (!Registered)
					{
						if (key != null)
						{
							KeyboardShortcut value = key.Value;
							if ((int)((KeyboardShortcut)(ref value)).MainKey != 0)
							{
								value = key.Value;
								return Input.GetKey(((KeyboardShortcut)(ref value)).MainKey);
							}
						}
						return false;
					}
					if (ZInput.instance != null)
					{
						return ZInput.GetButton(Name);
					}
					return false;
				}
			}

			internal Binding(JotunnIntegration owner, string name, ConfigEntry<KeyboardShortcut> key, bool settingsToggle)
			{
				this.owner = owner;
				shortName = name;
				this.key = key;
				SettingsToggle = settingsToggle;
				key.SettingChanged += OnChanged;
			}

			internal Binding(JotunnIntegration owner, string name, ConfigEntry<GamepadButton> gamepad, bool settingsToggle)
			{
				this.owner = owner;
				shortName = name;
				this.gamepad = gamepad;
				SettingsToggle = settingsToggle;
				gamepad.SettingChanged += OnChanged;
			}

			private void OnChanged(object sender, EventArgs args)
			{
				Refresh();
			}

			internal void Refresh()
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: 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)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Invalid comparison between Unknown and I4
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Invalid comparison between Unknown and I4
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: 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)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Expected O, but got Unknown
				if (disposed)
				{
					return;
				}
				Unregister();
				ConfigEntry<KeyboardShortcut>? obj = key;
				int num;
				if (obj == null)
				{
					num = 0;
				}
				else
				{
					KeyboardShortcut value = obj.Value;
					num = (int)((KeyboardShortcut)(ref value)).MainKey;
				}
				KeyCode val = (KeyCode)num;
				ConfigEntry<GamepadButton>? obj2 = gamepad;
				GamepadButton val2 = (GamepadButton)((obj2 != null) ? ((int)obj2.Value) : 0);
				if (((int)val == 0 && (int)val2 == 0) || ((int)val >= 323 && (int)val <= 329))
				{
					return;
				}
				try
				{
					if (owner.buttons.ContainsKey(Name))
					{
						throw new InvalidOperationException("Button name is already registered: " + Name);
					}
					config = new ButtonConfig
					{
						Name = shortName,
						Key = val,
						GamepadButton = val2,
						ActiveInGUI = true,
						ActiveInCustomGUI = SettingsToggle
					};
					InputManager.Instance.AddButton("com.kernelpanic.ironbound", config);
				}
				catch (Exception ex)
				{
					Unregister();
					owner.log.LogWarning((object)("Jotunn button registration failed" + ((key != null) ? "; using native key: " : "; controller binding disabled: ") + ex.Message));
				}
			}

			private void Unregister()
			{
				if (config == null)
				{
					return;
				}
				if (owner.buttons.TryGetValue(Name, out ButtonConfig value) && value == config)
				{
					owner.buttons.Remove(Name);
					if (ZInput.instance != null && owner.nativeButtons.GetValue(ZInput.instance) is IDictionary dictionary)
					{
						string[] array = new string[2]
						{
							Name,
							"Joy!" + Name
						};
						foreach (string text in array)
						{
							if (dictionary.Contains(text))
							{
								object obj = dictionary[text];
								dictionary.Remove(text);
								(owner.buttonAction.GetValue(obj) as IDisposable)?.Dispose();
							}
						}
						if (owner.presentationButtons.GetValue(ZInput.instance) is IDictionary dictionary2)
						{
							object[] array2 = (from object layout in dictionary2.Keys
								where (string)owner.layoutButtonName.GetValue(layout) == "Joy!" + Name
								select layout).ToArray();
							foreach (object obj2 in array2)
							{
								dictionary2.Remove(obj2);
							}
						}
					}
				}
				config = null;
			}

			public void Dispose()
			{
				if (!disposed)
				{
					disposed = true;
					if (key != null)
					{
						key.SettingChanged -= OnChanged;
					}
					if (gamepad != null)
					{
						gamepad.SettingChanged -= OnChanged;
					}
					Unregister();
				}
			}
		}

		internal const string Guid = "com.jotunn.jotunn";

		internal const string MinimumVersion = "2.30.2";

		private static JotunnIntegration? current;

		private readonly ManualLogSource log;

		private readonly Dictionary<string, ButtonConfig> buttons;

		private readonly FieldInfo nativeButtons;

		private readonly PropertyInfo buttonAction;

		private readonly FieldInfo presentationButtons;

		private readonly PropertyInfo layoutButtonName;

		private readonly List<Binding> bindings = new List<Binding>();

		private bool ownsBlock;

		private bool disposed;

		private int sceneHandle;

		internal Action? GuiRecreated;

		private JotunnIntegration(ManualLogSource log)
		{
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			this.log = log;
			_ = InputManager.Instance;
			buttons = (AccessTools.Field(typeof(InputManager), "Buttons")?.GetValue(null) as Dictionary<string, ButtonConfig>) ?? throw new NotSupportedException("Jotunn button cleanup registry changed.");
			nativeButtons = AccessTools.Field(typeof(ZInput), "m_buttons");
			buttonAction = AccessTools.Inner(typeof(ZInput), "ButtonDef").GetProperty("ButtonAction");
			presentationButtons = AccessTools.Field(typeof(ZInput), "m_presentationButtons");
			layoutButtonName = AccessTools.Inner(typeof(ZInput), "LayoutButton").GetProperty("Name");
			if (nativeButtons == null || buttonAction == null || presentationButtons == null || layoutButtonName == null || !typeof(IDictionary).IsAssignableFrom(presentationButtons.FieldType) || !typeof(IDictionary).IsAssignableFrom(nativeButtons.FieldType))
			{
				throw new NotSupportedException("Custom input cleanup API changed.");
			}
			Scene activeScene = SceneManager.GetActiveScene();
			sceneHandle = ((Scene)(ref activeScene)).handle;
			GUIManager.OnCustomGUIAvailable += OnGuiAvailable;
		}

		internal static void Require()
		{
			if (!Chainloader.PluginInfos.TryGetValue("com.jotunn.jotunn", out var value) || value.Metadata.Version < new Version("2.30.2"))
			{
				throw new InvalidOperationException("Ironbound requires Jotunn 2.30.2 or newer. Install it in BepInEx/plugins and restart Valheim.");
			}
		}

		internal static JotunnIntegration Create(ManualLogSource log)
		{
			Require();
			JotunnIntegration? result = (current = new JotunnIntegration(log));
			log.LogInfo((object)"Jotunn input/UI integration enabled.");
			return result;
		}

		internal Binding AddButton(string name, ConfigEntry<KeyboardShortcut> key, bool settingsToggle = false)
		{
			Binding binding = new Binding(this, name, key, settingsToggle);
			bindings.Add(binding);
			binding.Refresh();
			return binding;
		}

		internal Binding AddGamepadButton(string name, ConfigEntry<GamepadButton> key, bool settingsToggle = false)
		{
			Binding binding = new Binding(this, name, key, settingsToggle);
			bindings.Add(binding);
			binding.Refresh();
			return binding;
		}

		internal static bool AllowsButton(string name)
		{
			if (current == null)
			{
				return false;
			}
			foreach (Binding binding in current.bindings)
			{
				if (binding.SettingsToggle && binding.Registered && binding.Name == name)
				{
					return true;
				}
			}
			return false;
		}

		internal void Tick()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!disposed)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).handle != sceneHandle)
				{
					ownsBlock = false;
					sceneHandle = ((Scene)(ref activeScene)).handle;
				}
				bool flag = ((Scene)(ref activeScene)).name == "main" && (UiState.ModalOpen || UiState.Typing);
				if (flag != ownsBlock)
				{
					GUIManager.BlockInput(flag);
					ownsBlock = flag;
				}
			}
		}

		private void OnGuiAvailable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			ownsBlock = false;
			Scene activeScene = SceneManager.GetActiveScene();
			sceneHandle = ((Scene)(ref activeScene)).handle;
			GuiRecreated?.Invoke();
		}

		public void Dispose()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if (disposed)
			{
				return;
			}
			disposed = true;
			GUIManager.OnCustomGUIAvailable -= OnGuiAvailable;
			GuiRecreated = null;
			try
			{
				foreach (Binding binding in bindings)
				{
					UiLifetime.Cleanup(binding.Dispose, delegate(Exception exception)
					{
						log.LogWarning((object)("Input binding cleanup failed: " + exception));
					});
				}
			}
			finally
			{
				bindings.Clear();
				try
				{
					if (ownsBlock)
					{
						Scene activeScene = SceneManager.GetActiveScene();
						if (((Scene)(ref activeScene)).handle == sceneHandle)
						{
							GUIManager.BlockInput(false);
						}
					}
				}
				finally
				{
					ownsBlock = false;
					if (current == this)
					{
						current = null;
					}
				}
			}
		}
	}
	internal static class Ornaments
	{
		internal static TextMeshProUGUI Section(Transform parent, Theme theme, string text, float x, float y, float w)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return Ugui.Text(parent, text, text.ToLowerInvariant(), theme.Section, 16f, Palette.Muted, (TextAlignmentOptions)4097).At<TextMeshProUGUI>(x, y - 4f, w, 24f);
		}

		internal static void Rule(Transform parent, Theme theme, float x, float y, float w)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Ugui.Image(parent, "Rule", theme.White, Palette.Gold.WithAlpha(0.45f)).At<Image>(x, y, w, 1f);
			Ugui.Image(parent, "Rule Gem", theme.Diamond, Palette.Gold).At<Image>(x + w / 2f - 4f, y - 3.5f, 8f, 8f);
		}

		internal static TextMeshProUGUI Title(Transform parent, Theme theme, string text, float size)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return Ugui.Text(parent, "Title", text, theme.Heading, size, Palette.Gold, (TextAlignmentOptions)4097);
		}

		internal static Button Keycap(Transform parent, Theme theme, string label, float x, float y, float w, float h, Action onClick, float size = 13f)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			Button val = Ugui.Button(parent, label, theme.Button, theme.ButtonHover, onClick);
			val.At<Button>(x, y, w, h);
			TextMeshProUGUI text = Ugui.Text(((Component)val).transform, "Label", label, theme.Strong, size, Palette.Bone, (TextAlignmentOptions)514).Stretch<TextMeshProUGUI>(4f, 0f, 4f, 0f);
			((Component)(object)val).OnHover(delegate(bool on)
			{
				//IL_0010: 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)
				((Graphic)text).color = (on ? Palette.GoldBright : Palette.Bone);
			});
			return val;
		}
	}
	internal static class RecipeDetails
	{
		private static readonly Regex Tags = new Regex("<[^>]*>");

		private static readonly Regex Key = new Regex("^\\$[a-zA-Z0-9_]+");

		private static readonly string[] Titles = new string[7] { "PHYSICAL DAMAGE", "ELEMENTAL DAMAGE", "BLOCKING & PROTECTION", "ATTACK & RESOURCE USE", "NOURISHMENT", "EQUIPMENT", "EFFECTS & SPECIAL PROPERTIES" };

		internal static string Format(string tooltip, string flavor)
		{
			string text = (tooltip.StartsWith(flavor, StringComparison.Ordinal) ? tooltip.Substring(flavor.Length) : tooltip);
			List<string>[] array = new List<string>[Titles.Length];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new List<string>();
			}
			int num = 5;
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			string[] array2 = text.Replace("\r", "").Split(new char[1] { '\n' });
			for (int j = 0; j < array2.Length; j++)
			{
				string text2 = array2[j].Trim();
				if (text2.Length == 0)
				{
					flag = flag3;
					continue;
				}
				string value = Key.Match(Tags.Replace(text2, "")).Value;
				if (flag && flag3)
				{
					flag2 = true;
				}
				int num2 = (flag2 ? 6 : Group(value));
				if (value.Length == 0 && flag3 && !flag)
				{
					num2 = num;
				}
				if (flag && array[num2].Count > 0)
				{
					array[num2].Add("");
				}
				array[num2].Add(text2);
				num = num2;
				flag3 = true;
				flag = false;
			}
			StringBuilder stringBuilder = new StringBuilder();
			if (!string.IsNullOrWhiteSpace(flavor))
			{
				stringBuilder.Append("<i>").Append(flavor.Trim()).Append("</i>");
			}
			for (int k = 0; k < array.Length; k++)
			{
				if (array[k].Count != 0)
				{
					if (stringBuilder.Length > 0)
					{
						stringBuilder.Append("\n\n");
					}
					stringBuilder.Append("<size=10><b><cspace=0.8><color=").Append((k == 1) ? "#8FC1E8" : "#A99F8D").Append('>')
						.Append(Titles[k])
						.Append("</color></cspace></b></size>\n");
					stringBuilder.Append(string.Join("\n", array[k]));
				}
			}
			return stringBuilder.ToString().Replace("<color=orange>", "<color=#ECE5D6>").Replace("<color=yellow>", "<color=#A99F8D>")
				.Replace("<color=#ff8080ff>", "<color=#F07B70>")
				.Replace("<color=#ffff80ff>", "<color=#E8C04A>")
				.Replace("<color=#9090ffff>", "<color=#9A7BEA>");
		}

		private static int Group(string key)
		{
			switch (key)
			{
			case "$inventory_damage":
			case "$inventory_pierce":
			case "$inventory_blunt":
			case "$inventory_slash":
			case "$inventory_chop":
			case "$inventory_pickaxe":
				return 0;
			case "$inventory_poison":
			case "$inventory_spirit":
			case "$inventory_frost":
			case "$inventory_fire":
			case "$inventory_lightning":
				return 1;
			case "$item_blockarmor":
			case "$item_blockforce":
			case "$item_parrybonus":
			case "$item_armor":
			case "$item_parryadrenaline":
				return 2;
			case "$item_staminahold":
			case "$item_staminause":
			case "$item_knockback":
			case "$item_healthuse":
			case "$item_healthhitreturn":
			case "$item_eitruse":
			case "$item_eitrhitreturn":
			case "$item_backstab":
			case "$item_damagemultipliertotal":
			case "$item_damagemultiplierhp":
				return 3;
			case "$item_food_health":
			case "$item_food_regen":
			case "$item_food_eitr":
			case "$item_food_stamina":
			case "$item_food_duration":
				return 4;
			case "$item_repairlevel":
			case "$item_durability":
			case "$item_noteleport":
			case "$item_onehanded":
			case "$item_twohanded":
			case "$item_value":
			case "$item_crafter":
			case "$item_quality":
			case "$item_weight":
				return 5;
			default:
				return 6;
			}
		}
	}
	internal static class SystemScroll
	{
		private const uint GetWheelScrollLines = 104u;

		private const uint PageScroll = uint.MaxValue;

		private static float cached = -1f;

		private static float readAt = -100f;

		private static bool unavailable;

		[DllImport("user32.dll", SetLastError = true)]
		private static extern bool SystemParametersInfo(uint action, uint param, ref uint value, uint winIni);

		internal static float? Lines()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			if (unavailable || (int)Application.platform != 2)
			{
				return null;
			}
			if (Time.unscaledTime - readAt < 3f)
			{
				if (!(cached > 0f))
				{
					return null;
				}
				return cached;
			}
			readAt = Time.unscaledTime;
			try
			{
				uint value = 3u;
				if (!SystemParametersInfo(104u, 0u, ref value, 0u))
				{
					return null;
				}
				cached = ((value == uint.MaxValue) ? 12f : ((float)value));
			}
			catch (Exception)
			{
				unavailable = true;
				return null;
			}
			if (!(cached > 0f))
			{
				return null;
			}
			return cached;
		}
	}
	internal sealed class TextOutline
	{
		private readonly TMP_Text source;

		private readonly TextMeshProUGUI[] edges;

		private readonly Vector2[] offsets;

		private static readonly Regex ColorTags = new Regex("</?color(?:=[^>]*)?>", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

		private string sourceText;

		private string outlineText;

		internal TextOutline(TMP_Text source, bool world = false, float opacity = 1f, float radiusScale = 1f)
		{
			//IL_0099: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			this.source = source;
			edges = (TextMeshProUGUI[])(object)new TextMeshProUGUI[world ? 17 : 8];
			offsets = (Vector2[])(object)new Vector2[edges.Length];
			sourceText = source.text;
			outlineText = ColorTags.Replace(sourceText, "");
			RectTransform rectTransform = source.rectTransform;
			for (int i = 0; i < edges.Length; i++)
			{
				bool flag = world && i < 9;
				float num = (float)(world ? (i - 9) : i) * (float)Math.PI / 4f;
				Color color = (world ? Palette.Hex(658702, flag ? 0.097f : 1f) : Palette.Hex(2699311, 0.32f));
				color.a *= Mathf.Clamp01(opacity);
				TextMeshProUGUI val = Ugui.Text(source.transform.parent, ((Object)source).name + " outline " + i, source.richText ? outlineText : sourceText, source.font, source.fontSize, color, source.alignment);
				RectTransform rectTransform2 = ((TMP_Text)val).rectTransform;
				rectTransform2.anchorMin = rectTransform.anchorMin;
				rectTransform2.anchorMax = rectTransform.anchorMax;
				rectTransform2.pivot = rectTransform.pivot;
				rectTransform2.sizeDelta = rectTransform.sizeDelta;
				offsets[i] = (flag ? (new Vector2(0f, -2f) + ((i == 8) ? Vector2.zero : (new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * 3f))) : (new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * (world ? 1f : 0.65f)));
				ref Vector2 reference = ref offsets[i];
				reference *= radiusScale;
				rectTransform2.anchoredPosition = rectTransform.anchoredPosition + offsets[i];
				((TMP_Text)val).overflowMode = source.overflowMode;
				((TMP_Text)val).textWrappingMode = source.textWrappingMode;
				((TMP_Text)val).maxVisibleLines = source.maxVisibleLines;
				((TMP_Text)val).enableAutoSizing = source.enableAutoSizing;
				((TMP_Text)val).fontSizeMin = source.fontSizeMin;
				((TMP_Text)val).fontSizeMax = source.fontSizeMax;
				((TMP_Text)val).richText = source.richText;
				((TMP_Text)val).fontWeight = source.fontWeight;
				((TMP_Text)val).characterSpacing = source.characterSpacing;
				((TMP_Text)val).lineSpacing = source.lineSpacing;
				((TMP_Text)val).transform.SetSiblingIndex(source.transform.GetSiblingIndex());
				edges[i] = val;
			}
		}

		internal void Sync()
		{
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: 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_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			if (sourceText != source.text)
			{
				sourceText = source.text;
				outlineText = ColorTags.Replace(sourceText, "");
			}
			for (int i = 0; i < edges.Length; i++)
			{
				TextMeshProUGUI val = edges[i];
				if (((Component)val).gameObject.activeSelf != ((Component)source).gameObject.activeSelf)
				{
					((Component)val).gameObject.SetActive(((Component)source).gameObject.activeSelf);
				}
				((Behaviour)val).enabled = ((Behaviour)source).enabled;
				((TMP_Text)val).text = (source.richText ? outlineText : sourceText);
				if ((Object)(object)((TMP_Text)val).font != (Object)(object)source.font)
				{
					((TMP_Text)val).font = source.font;
				}
				if (((TMP_Text)val).fontSize != source.fontSize)
				{
					((TMP_Text)val).fontSize = source.fontSize;
				}
				if (((TMP_Text)val).overflowMode != source.overflowMode)
				{
					((TMP_Text)val).overflowMode = source.overflowMode;
				}
				if (((TMP_Text)val).textWrappingMode != source.textWrappingMode)
				{
					((TMP_Text)val).textWrappingMode = source.textWrappingMode;
				}
				if (((TMP_Text)val).maxVisibleLines != source.maxVisibleLines)
				{
					((TMP_Text)val).maxVisibleLines = source.maxVisibleLines;
				}
				if (((TMP_Text)val).enableAutoSizing != source.enableAutoSizing)
				{
					((TMP_Text)val).enableAutoSizing = source.enableAutoSizing;
				}
				if (((TMP_Text)val).fontSizeMin != source.fontSizeMin)
				{
					((TMP_Text)val).fontSizeMin = source.fontSizeMin;
				}
				if (((TMP_Text)val).fontSizeMax != source.fontSizeMax)
				{
					((TMP_Text)val).fontSizeMax = source.fontSizeMax;
				}
				if (((TMP_Text)val).characterSpacing != source.characterSpacing)
				{
					((TMP_Text)val).characterSpacing = source.characterSpacing;
				}
				if (((TMP_Text)val).lineSpacing != source.lineSpacing)
				{
					((TMP_Text)val).lineSpacing = source.lineSpacing;
				}
				if ((Object)(object)((TMP_Text)val).spriteAsset != (Object)(object)source.spriteAsset)
				{
					((TMP_Text)val).spriteAsset = source.spriteAsset;
				}
				RectTransform rectTransform = ((TMP_Text)val).rectTransform;
				rectTransform.anchorMin = source.rectTransform.anchorMin;
				rectTransform.anchorMax = source.rectTransform.anchorMax;
				rectTransform.pivot = source.rectTransform.pivot;
				((TMP_Text)val).alignment = source.alignment;
				((TMP_Text)val).richText = source.richText;
				((TMP_Text)val).fontWeight = source.fontWeight;
				Vector2 val2 = source.rectTransform.anchoredPosition + offsets[i];
				if (rectTransform.anchoredPosition != val2)
				{
					rectTransform.anchoredPosition = val2;
				}
				if (rectTransform.sizeDelta != source.rectTransform.sizeDelta)
				{
					rectTransform.sizeDelta = source.rectTransform.sizeDelta;
				}
			}
		}
	}
	internal static class Palette
	{
		internal const float HudGlassOpacity = 0.58f;

		internal static readonly Color HudGlass = Hex(790289, 0.58f);

		internal static readonly Color HudWetGlass = Hex(1516845, 0.58f);

		internal static readonly Color Backdrop = Hex(328965, 0.62f);

		internal static readonly Color Obsidian = Hex(1054489);

		internal static readonly Color Panel = Hex(1054489, 0.78f);

		internal static readonly Color Card = Hex(2039836);

		internal static readonly Color CardHover = Hex(2829607);

		internal static readonly Color Moss = Hex(3553841);

		internal static readonly Color Rule = Hex(6443828);

		internal static readonly Color Gold = Hex(12953180);

		internal static readonly Color GoldBright = Hex(14928773);

		internal static readonly Color GoldDim = Hex(6443828);

		internal static readonly Color Tan = Hex(12491374);

		internal static readonly Color Bone = Hex(14998731);

		internal static readonly Color Muted = Hex(14998731, 0.6f);

		internal static readonly Color Faint = Hex(14998731, 0.4f);

		internal static readonly Color Dim = Hex(14998731, 0.3f);

		internal static readonly Color Key = Hex(15392704);

		internal static readonly Color Alert = Hex(14033948);

		internal static readonly Color Crimson = Hex(11019806);

		internal static readonly Color Ember = Hex(14704942);

		internal static readonly Color Health = Hex(14043710);

		internal static readonly Color Stamina = Hex(15253578);

		internal static readonly Color Eitr = Hex(7974854);

		internal static readonly Color Success = Hex(9547128);

		internal static readonly Color Frost = Hex(7974854);

		internal static readonly Color Ink = Hex(986895);

		internal static readonly Color SwitchOn = Hex(3025442);

		internal static readonly Color Iron = Hex(5397593);

		internal static readonly Color ConfigRow = Hex(1514781, 0.96f);

		internal static readonly Color ConfigHover = Hex(2370602, 0.98f);

		internal static Color Hex(int rgb, float alpha = 1f)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f, alpha);
		}

		internal static Color WithAlpha(this Color color, float alpha)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Color(color.r, color.g, color.b, alpha);
		}
	}
	internal sealed class Theme : IDisposable
	{
		private enum Surface
		{
			Iron,
			Carved,
			Leather,
			Recess,
			Mask
		}

		private sealed class ChamferStyle
		{
			internal Color Fill;

			internal Color Border;

			internal Sprite Base;

			internal int Cut;

			internal int Seed;

			internal Surface Material;

			internal readonly Dictionary<(int, int, bool), Sprite> Sized = new Dictionary<(int, int, bool), Sprite>();
		}

		private readonly List<Object> owned = new List<Object>();

		private TMP_FontAsset? heading;

		private TMP_FontAsset? body;

		private TMP_FontAsset? strong;

		private TMP_FontAsset? numbers;

		private TMP_FontAsset? runic;

		private TMP_FontAsset? subtle;

		private TMP_FontAsset? serif;

		private float nextFontScan;

		internal readonly Sprite InventoryShield;

		internal readonly Sprite HudRune;

		internal readonly Sprite HudRing;

		internal readonly Sprite HudDashedRing;

		internal readonly Sprite HudPortraitRing;

		internal readonly Sprite HudTile;

		internal readonly Sprite HudTileEdge;

		internal readonly Sprite HudMoon;

		internal readonly Sprite HudFlame;

		internal readonly Sprite HudBowl;

		internal readonly Sprite HudBottle;

		internal readonly Sprite HudBar;

		internal readonly Sprite HudStag;

		internal readonly Sprite HudGlow;

		internal readonly Sprite HudHatch;

		internal readonly Sprite HudVignette;

		internal readonly Sprite HudEmptyEdge;

		internal readonly Sprite HudStar;

		internal readonly Sprite HudBackpack;

		internal readonly Sprite HudActionSlot;

		internal readonly Sprite HudActionEdge;

		internal readonly Sprite HudActionEmptyEdge;

		internal readonly Sprite PackEmptyEdge;

		internal readonly Sprite PackSurface;

		internal readonly Sprite PackEdge;

		internal readonly Sprite PackPill;

		internal readonly Sprite PackPillEdge;

		internal readonly Sprite HudKeySurface;

		internal readonly Sprite HudKeyEdge;

		internal readonly Sprite SkillPill;

		internal readonly Sprite SkillPillEdge;

		internal readonly Sprite SkillUp;

		internal readonly Sprite White;

		internal readonly Sprite Diamond;

		internal readonly Sprite Knot;

		internal readonly Sprite Window;

		internal readonly Sprite Board;

		internal readonly Sprite Card;

		internal readonly Sprite CardHover;

		internal readonly Sprite Button;

		internal readonly Sprite ButtonHover;

		internal readonly Sprite Primary;

		internal readonly Sprite PrimaryHover;

		internal readonly Sprite SegmentOn;

		internal readonly Sprite SegmentOnHover;

		internal readonly Sprite Field;

		internal readonly Sprite FieldFocus;

		internal readonly Sprite ConfigWindow;

		internal readonly Sprite ConfigCard;

		internal readonly Sprite ConfigCardHover;

		internal readonly Sprite ConfigButton;

		internal readonly Sprite ConfigButtonHover;

		internal readonly Sprite ConfigSelected;

		internal readonly Sprite ConfigSelectedHover;

		internal readonly Sprite ConfigField;

		internal readonly Sprite ConfigFieldFocus;

		internal readonly Sprite HudFrame;

		internal readonly Sprite Minimal;

		internal readonly Sprite Tooltip;

		internal readonly Sprite StatusPlate;

		internal readonly Sprite HudWell;

		internal readonly Sprite ArtCut;

		internal readonly Sprite ArtScene;

		internal readonly Sprite Shade;

		internal readonly Sprite Plate;

		internal readonly Sprite Slot;

		internal readonly Sprite SlotHover;

		internal readonly Sprite SlotRing;

		internal readonly Sprite ButtonOff;

		internal readonly Sprite NoTeleport;

		internal readonly Sprite IconSword;

		internal readonly Sprite IconFood;

		internal readonly Sprite IconHammer;

		internal readonly Sprite IconHome;

		internal readonly Sprite IconPortal;

		internal readonly Sprite IconShip;

		internal readonly Sprite IconPlayer;

		internal readonly Sprite IconHelm;

		internal readonly Sprite IconArrow;

		internal readonly Sprite IconIngot;

		internal readonly Sprite IconSearch;

		internal readonly Sprite IconCheck;

		internal readonly Sprite IconOther;

		internal readonly Sprite IconStack;

		internal readonly Sprite IconSort;

		internal readonly Sprite IconUpgrade;

		internal readonly Sprite IconRepair;

		internal readonly Sprite IconHeart;

		internal readonly Sprite IconBolt;

		internal readonly Sprite IconDrop;

		internal readonly Sprite GlyphSlash;

		internal readonly Sprite GlyphPierce;

		internal readonly Sprite GlyphBlunt;

		internal readonly Sprite GlyphChop;

		internal readonly Sprite GlyphPickaxe;

		internal readonly Sprite GlyphFire;

		internal readonly Sprite GlyphFrost;

		internal readonly Sprite GlyphLightning;

		internal readonly Sprite GlyphPoison;

		internal readonly Sprite GlyphSpirit;

		internal readonly Sprite GlyphShield;

		internal readonly Sprite GlyphHealth;

		internal readonly Sprite GlyphStamina;

		internal readonly Sprite GlyphEitr;

		internal readonly Sprite GlyphWeight;

		internal readonly Sprite GlyphCoin;

		internal readonly Sprite GlyphAlert;

		internal readonly Sprite GlyphEffect;

		internal readonly Sprite GlyphMeal;

		internal readonly Sprite Cap;

		internal readonly Sprite Emblem;

		internal readonly Sprite Reticle;

		internal readonly Sprite Braid;

		internal readonly Sprite Disc;

		internal readonly Sprite Ring;

		internal readonly Sprite Medallion;

		internal readonly Sprite BarFill;

		internal readonly Sprite Tick;

		internal readonly Sprite HatchCap;

		internal readonly Sprite PowerKey;

		internal readonly Sprite Arc;

		internal const float RingInner = 116f;

		internal readonly MonochromeIcons Mono = new MonochromeIcons();

		internal readonly LiquidSkin Blood;

		internal readonly LiquidSkin Mead;

		internal readonly LiquidSkin Arcane;

		internal static Theme? Current;

		internal static Func<bool> ChipEdges = () => false;

		private readonly Dictionary<Sprite, ChamferStyle> styles = new Dictionary<Sprite, ChamferStyle>();

		private readonly Dictionary<Sprite, ChamferStyle> sizedStyles = new Dictionary<Sprite, ChamferStyle>();

		private const float KnotReach = 31f;

		internal TMP_FontAsset? Heading
		{
			get
			{
				TMP_FontAsset obj = heading;
				if (obj == null)
				{
					TMP_FontAsset? obj2 = FontLibrary.Get("Cinzel-SemiBold.ttf") ?? FindFont("Norsebold", "Norse") ?? Body;
					TMP_FontAsset val = obj2;
					heading = obj2;
					obj = val;
				}
				return obj;
			}
		}

		internal TMP_FontAsset? Display => Heading;

		internal TMP_FontAsset? Section => Heading;

		internal TMP_FontAsset? Body
		{
			get
			{
				TMP_FontAsset obj = body;
				if (obj == null)
				{
					TMP_FontAsset? obj2 = FontLibrary.Get("BarlowSemiCondensed-Regular.ttf") ?? Fallback();
					TMP_FontAsset val = obj2;
					body = obj2;
					obj = val;
				}
				return obj;
			}
		}

		internal TMP_FontAsset? Numbers
		{
			get
			{
				TMP_FontAsset obj = numbers;
				if (obj == null)
				{
					TMP_FontAsset? obj2 = FontLibrary.Get("BarlowSemiCondensed-Bold.ttf") ?? Body;
					TMP_FontAsset val = obj2;
					numbers = obj2;
					obj = val;
				}
				return obj;
			}
		}

		internal TMP_FontAsset? Runic
		{
			get
			{
				TMP_FontAsset obj = runic;
				if (obj == null)
				{
					TMP_FontAsset? obj2 = FontLibrary.Get("NotoSansRunic-Regular.ttf") ?? Body;
					TMP_FontAsset val = obj2;
					runic = obj2;
					obj = val;
				}
				return obj;
			}
		}

		internal TMP_FontAsset? Strong
		{
			get
			{
				if (Object.op_Implicit((Object)(object)strong))
				{
					return strong;
				}
				strong = FontLibrary.Get("BarlowSemiCondensed-SemiBold.ttf") ?? Body;
				if (Object.op_Implicit((Object)(object)strong) && Object.op_Implicit((Object)(object)Numbers))
				{
					strong.fontWeightTable[7].regularTypeface = Numbers;
				}
				return strong;
			}
		}

		internal TMP_FontAsset? Subtle
		{
			get
			{
				TMP_FontAsset obj = subtle;
				if (obj == null)
				{
					TMP_FontAsset? obj2 = FontLibrary.Get("BarlowSemiCondensed-Italic.ttf") ?? Body;
					TMP_FontAsset val = obj2;
					subtle = obj2;
					obj = val;
				}
				return obj;
			}
		}

		internal Theme()
		{
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_070d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0712: Unknown result type (might be due to invalid IL or missing references)
			//IL_071c: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0734: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0751: Unknown result type (might be due to invalid IL or missing references)
			//IL_0756: Unknown result type (might be due to invalid IL or missing references)
			//IL_0760: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			//IL_0778: Unknown result type (might be due to invalid IL or missing references)
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_0795: Unknown result type (might be due to invalid IL or missing references)
			//IL_079a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07de: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0809: Unknown result type (might be due to invalid IL or missing references)
			//IL_080e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0821: Unknown result type (might be due to invalid IL or missing references)
			//IL_082b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0830: Unknown result type (might be due to invalid IL or missing references)
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_084d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0852: Unknown result type (might be due to invalid IL or missing references)
			//IL_086f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0874: Unknown result type (might be due to invalid IL or missing references)
			//IL_087e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_0899: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08be: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_090d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0912: Unknown result type (might be due to invalid IL or missing references)
			//IL_091c: Unknown result type (might be due to invalid IL or missing references)
			//IL_093c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0941: Unknown result type (might be due to invalid IL or missing references)
			//IL_094b: Unknown result type (might be due to invalid IL or missing references)
			//IL_096b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0970: Unknown result type (might be due to invalid IL or missing references)
			//IL_0990: Unknown result type (might be due to invalid IL or missing references)
			//IL_0995: Unknown result type (might be due to invalid IL or missing references)
			//IL_099f: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a29: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a94: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b04: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b36: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cdb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d95: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4a: Unknown result type (might be due to invalid IL or missing references)
			Current = this;
			White = Plain(Make(4, 4, (int _, int _) => Color.white));
			PackSurface = RoundedPanel(12f, outline: false);
			PackEdge = RoundedPanel(12f, outline: true);
			PackPill = RoundedPanel(14f, outline: false);
			PackPillEdge = RoundedPanel(14f, outline: true);
			SkillPill = RoundedPanel(25f, outline: false);
			SkillPillEdge = RoundedPanel(25f, outline: true);
			SkillUp = Plain(LineIcon(44, 0f, (Vector2 p) => Lines(Segment(p, new Vector2(32f, 14f), new Vector2(32f, 50f), 0f), Segment(p, new Vector2(16f, 34f), new Vector2(32f, 50f), 0f), Segment(p, new Vector2(32f, 50f), new Vector2(48f, 34f), 0f))));
			HudKeySurface = RoundedPanel(5f, outline: false);
			HudKeyEdge = RoundedPanel(5f, outline: true);
			HudRune = Plain(LineIcon(96, 0f, (Vector2 p) => Lines(Segment(p, new Vector2(32f, 7f), new Vector2(32f, 57f), 0f), Segment(p, new Vector2(19f, 7f), new Vector2(45f, 7f), 0f), Segment(p, new Vector2(19f, 57f), new Vector2(45f, 57f), 0f))));
			HudStag = Plain(LineIcon(96, 0f, (Vector2 p) => Lines(Segment(p, new Vector2(32f, 7f), new Vector2(32f, 33f), 0f), Segment(p, new Vector2(32f, 33f), new Vector2(20f, 44f), 0f), Segment(p, new Vector2(20f, 44f), new Vector2(16f, 58f), 0f), Segment(p, new Vector2(32f, 33f), new Vector2(44f, 44f), 0f), Segment(p, new Vector2(44f, 44f), new Vector2(48f, 58f), 0f), Segment(p, new Vector2(20f, 44f), new Vector2(10f, 48f), 0f), Segment(p, new Vector2(44f, 44f), new Vector2(54f, 48f), 0f), Segment(p, new Vector2(27f, 37f), new Vector2(20f, 33f), 0f), Segment(p, new Vector2(37f, 37f), new Vector2(44f, 33f), 0f))));
			HudRing = Plain(Make(128, 128, delegate(int x, int y)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = new Vector2((float)x + 0.5f - 64f, (float)y + 0.5f - 64f);
				float magnitude = ((Vector2)(ref val)).magnitude;
				return Color.white.WithAlpha(Mathf.Clamp01(1f - Mathf.Abs(magnitude - 61f) + 2f));
			}));
			HudDashedRing = Plain(Make(128, 128, delegate(int x, int y)
			{
				//IL_0041: 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_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)x + 0.5f - 64f, (float)y + 0.5f - 64f);
				float num4 = Mathf.Clamp01(3f - Mathf.Abs(((Vector2)(ref val)).magnitude - 61f));
				float num5 = Mathf.Repeat(Mathf.Atan2(val.y, val.x) / ((float)Math.PI * 2f) * 16f, 1f);
				float num6 = Mathf.Clamp01(Mathf.Min(num5, 0.65f - num5) * 24f);
				return Color.white.WithAlpha(num4 * num6);
			}));
			HudPortraitRing = Plain(Make(256, 256, delegate(int x, int y)
			{
				//IL_0041: 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_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)x + 0.5f - 128f, (float)y + 0.5f - 128f);
				float alpha = Mathf.Clamp01(2.3f - Mathf.Abs(((Vector2)(ref val)).magnitude - 125f));
				return ((Mathf.Repeat(Mathf.Atan2(val.y, val.x) / ((float)Math.PI * 2f) * 24f, 1f) < 0.12f) ? Palette.Bone : Palette.Gold).WithAlpha(alpha);
			}));
			HudTile = Plain(Make(96, 96, delegate(int x, int y)
			{
				//IL_0039: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(Mathf.Abs((float)x + 0.5f - 48f) - 27f, Mathf.Abs((float)y + 0.5f - 48f) - 27f);
				Vector2 val2 = new Vector2(Mathf.Max(val.x, 0f), Mathf.Max(val.y, 0f));
				float num4 = ((Vector2)(ref val2)).magnitude + Mathf.Min(Mathf.Max(val.x, val.y), 0f) - 19f;
				return Color.white.WithAlpha(Mathf.Clamp01(0.5f - num4));
			}));
			HudTileEdge = Plain(Make(96, 96, delegate(int x, int y)
			{
				//IL_0039: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(Mathf.Abs((float)x + 0.5f - 48f) - 27f, Mathf.Abs((float)y + 0.5f - 48f) - 27f);
				Vector2 val2 = new Vector2(Mathf.Max(val.x, 0f), Mathf.Max(val.y, 0f));
				float num4 = ((Vector2)(ref val2)).magnitude + Mathf.Min(Mathf.Max(val.x, val.y), 0f) - 19f;
				return Color.white.WithAlpha(Mathf.Clamp01(0.5f - num4) * Mathf.Clamp01(num4 + 3f));
			}));
			HudEmptyEdge = Plain(Make(96, 96, delegate(int x, int y)
			{
				//IL_0039: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(Mathf.Abs((float)x + 0.5f - 48f) - 27f, Mathf.Abs((float)y + 0.5f - 48f) - 27f);
				Vector2 val2 = new Vector2(Mathf.Max(val.x, 0f), Mathf.Max(val.y, 0f));
				float num4 = ((Vector2)(ref val2)).magnitude + Mathf.Min(Mathf.Max(val.x, val.y), 0f) - 19f;
				return Color.white.WithAlpha(Mathf.Clamp01(0.5f - num4) * Mathf.Clamp01(num4 + 3f) * (float)(((x + y) % 13 < 8) ? 1 : 0));
			}));
			HudActionSlot = Plain(Make(116, 116, (int x, int y) => Color.white.WithAlpha(Mathf.Clamp01(0.5f - ActionSlotDistance(x, y)))));
			HudActionEdge = Plain(Make(116, 116, delegate(int x, int y)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				float num4 = ActionSlotDistance(x, y);
				return Color.white.WithAlpha(Mathf.Clamp01(0.5f - num4) * Mathf.Clamp01(num4 + 2f));
			}));
			HudActionEmptyEdge = Plain(Make(116, 116, delegate(int x, int y)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				float num4 = ActionSlotDistance(x, y);
				return Color.white.WithAlpha(Mathf.Clamp01(0.5f - num4) * Mathf.Clamp01(num4 + 2f) * (float)(((x + y) % 16 < 10) ? 1 : 0));
			}));
			PackEmptyEdge = Plain(Make(116, 116, delegate(int x, int y)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				float num4 = ActionSlotDistance(x, y);
				return Color.white.WithAlpha(Mathf.Clamp01(0.5f - num4) * Mathf.Clamp01(num4 + 3.5f) * (float)(((x + y) % 20 < 13) ? 1 : 0));
			}));
			Vector2[] star = (Vector2[])(object)new Vector2[10];
			for (int num = 0; num < star.Length; num++)
			{
				float num2 = (float)Math.PI / 2f + (float)num * (float)Math.PI / 5f;
				float num3 = ((num % 2 == 0) ? 15f : 6.5f);
				star[num] = new Vector2(16f + Mathf.Cos(num2) * num3, 16f + Mathf.Sin(num2) * num3);
			}
			HudStar = Plain(Make(32, 32, delegate(int x, int y)
			{
				//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_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: 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_00dd: 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_008b: 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_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor((float)x + 0.5f, (float)y + 0.5f);
				bool flag = false;
				float num4 = float.MaxValue;
				int num5 = 0;
				int num6 = star.Length - 1;
				while (num5 < star.Length)
				{
					Vector2 val2 = star[num5];
					Vector2 val3 = star[num6];
					num4 = Mathf.Min(num4, Segment(val, val2, val3, 0f));
					if (val2.y > val.y != val3.y > val.y && val.x < (val3.x - val2.x) * (val.y - val2.y) / (val3.y - val2.y) + val2.x)
					{
						flag = !flag;
					}
					num6 = num5++;
				}
				return Color.white.WithAlpha(Mathf.Clamp01(0.5f + (flag ? num4 : (0f - num4))));
			}));
			HudBackpack = Plain(Make(64, 64, delegate(int x, int y)
			{
				//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_0026: 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)
				//IL_0055: 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_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: 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_00ff: Unknown result type (might be due to invalid IL or m