Decompiled source of Soul Links v1.0.0

plugins/SoulLinkEquipment/SoulLink.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Items;
using RoR2.UI;
using SoulLink.Items;
using SoulLink.UI;
using SoulLink.Util;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SoulLink")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6cdfdf78efb80824d0c4c3e5346789eb5dd7fa5a")]
[assembly: AssemblyProduct("SoulLink")]
[assembly: AssemblyTitle("SoulLink")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 SoulLink
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("BlueB.SoulLinkEquipment", "SoulLinkEquipment", "1.0.0")]
	public class SoulLink : BaseUnityPlugin
	{
		public const string PluginGUID = "BlueB.SoulLinkEquipment";

		public const string PluginAuthor = "BlueB";

		public const string PluginName = "SoulLinkEquipment";

		public const string PluginVersion = "1.0.0";

		private bool hudInitialized;

		private static ConfigEntry<KeyboardShortcut> uiOption1Key;

		private static ConfigEntry<KeyboardShortcut> uiOption2Key;

		private static ConfigEntry<KeyboardShortcut> uiOption3Key;

		private static ConfigEntry<KeyboardShortcut> uiOption4Key;

		private static ConfigEntry<KeyboardShortcut> uiOption5Key;

		private static ConfigEntry<KeyboardShortcut> uiOption6Key;

		private static ConfigEntry<KeyboardShortcut> uiOption7Key;

		private static ConfigEntry<KeyboardShortcut> uiOption8Key;

		private static ConfigEntry<KeyboardShortcut> uiOption9Key;

		private static ConfigEntry<KeyboardShortcut> uiPagingKey;

		private static ConfigEntry<bool> isLunarEquip;

		private static ConfigEntry<float> customCooldown;

		private static ConfigEntry<bool> useRandomBond;

		private static ConfigEntry<bool> allowHeretic;

		public static PluginInfo SavedInfo { get; private set; }

		public void Awake()
		{
			SavedInfo = ((BaseUnityPlugin)this).Info;
			Log.Init(((BaseUnityPlugin)this).Logger);
			AssetUtil.Init();
			Log.Debug("Asset Bundle loaded from stream. (allegedly)");
			InitializeConfigOptions();
			SoulLinkEquip.Init();
		}

		private void Update()
		{
		}

		private void InitializeConfigOptions()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_004b: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_006d: 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_008c: Expected O, but got Unknown
			//IL_008c: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00f2: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_012e: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_0155: 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_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_017b: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_01b2: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Expected O, but got Unknown
			//IL_01e9: Expected O, but got Unknown
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Expected O, but got Unknown
			//IL_0220: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Expected O, but got Unknown
			//IL_0257: Expected O, but got Unknown
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Expected O, but got Unknown
			//IL_028e: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Expected O, but got Unknown
			//IL_02c5: Expected O, but got Unknown
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Expected O, but got Unknown
			//IL_02fc: Expected O, but got Unknown
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Expected O, but got Unknown
			//IL_0333: Expected O, but got Unknown
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Expected O, but got Unknown
			//IL_036a: Expected O, but got Unknown
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Expected O, but got Unknown
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Expected O, but got Unknown
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Expected O, but got Unknown
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Expected O, but got Unknown
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Expected O, but got Unknown
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Expected O, but got Unknown
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Expected O, but got Unknown
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Expected O, but got Unknown
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Expected O, but got Unknown
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("This mod adds 1 configurable equipment to the game that lets the player transform between any 2 survivors. Change the menu keybinds, item tier, and tweak specific values here.");
			Sprite modIcon = AssetUtil.LoadSprite("SoulLinkModIcon.png");
			ModSettingsManager.SetModIcon(modIcon);
			string text = "Configuration";
			isLunarEquip = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "Make Lunar Equipment"), false, new ConfigDescription("Do you want the Soul Links to be a Lunar equipment? If this is enabled, the item tier will change to Lunar, so they will no longer spawn in Equipment Barrels. The functionality is the same.\n\nBy default, this is disabled, meaning they will be a standard orange Equipment. As a standard Equipment, Scavengers have a chance to spawn with this Equipment.", (AcceptableValueBase)null, Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(isLunarEquip, true));
			customCooldown = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition(text, "Equipment Cooldown"), 60f, new ConfigDescription("Set a custom cooldown (in seconds) for the Soul Links to make them more balanced (or more broken). Tweak away to your heart's content.\n\nBy default, this timer is set to 60, making the equipment useable once per minute.", (AcceptableValueBase)null, Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(customCooldown));
			customCooldown.SettingChanged += delegate
			{
				if (customCooldown.Value >= 1f)
				{
					SoulLinkEquip.equipDef.cooldown = customCooldown.Value;
				}
				else
				{
					customCooldown.Value = 1f;
				}
			};
			useRandomBond = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "Bond to Random Survivor"), false, new ConfigDescription("If you don't want to navigate the UI menu or would just like some more randomness in your life, checking this box will make it so won't be able to pick your transform target. Instead, using the equipment will bond you to a random available survivor on your first use.\n\nNote: This is not the recommended way to use the mod, but I added it for a little extra fun. By default, this is false. Please note that this still links between two survivors -- your starting character and one randomly chosen on first use. This does not give a random survivor every roll.", (AcceptableValueBase)null, Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(useRandomBond));
			allowHeretic = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition(text, "Allow Heretic"), true, new ConfigDescription("By checking this box, you are allowing Heretic into the pool of selectable survivors. Heretic does not come with any of the four Heresy items, meaning all four of her abilities will be Nevermore (unless you have one of the Heresy items).\n\nBy default, this value is true because funny, but also because you can simply not choose her. You may want to disable this if you are using random selection.", (AcceptableValueBase)null, Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(allowHeretic));
			string text2 = "Keybinds";
			uiOption1Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "First Option Select"), new KeyboardShortcut((KeyCode)49, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the first, or top-left, option in the Soul Links UI menu. By default this is Numrow 1.\n\nXOO\nOOO\nOOO", (AcceptableValueBase)null, Array.Empty<object>()));
			uiOption2Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Second Option Select"), new KeyboardShortcut((KeyCode)50, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the second, or top-center, option in the Soul Links UI menu. By default this is Numrow 2.\n\nOXO\nOOO\nOOO", (AcceptableValueBase)null, Array.Empty<object>()));
			uiOption3Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Third Option Select"), new KeyboardShortcut((KeyCode)51, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the third, or top-right, option in the Soul Links UI menu. By default this is Numrow 3.\n\nOOX\nOOO\nOOO", (AcceptableValueBase)null, Array.Empty<object>()));
			uiOption4Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Fourth Option Select"), new KeyboardShortcut((KeyCode)52, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the fourth, or middle-left, option in the Soul Links UI menu. By default this is Numrow 4.\n\nOOO\nXOO\nOOO", (AcceptableValueBase)null, Array.Empty<object>()));
			uiOption5Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Fifth Option Select"), new KeyboardShortcut((KeyCode)53, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the fifth, or middle-center, option in the Soul Links UI menu. By default this is Numrow 5.\n\nOOO\nOXO\nOOO", (AcceptableValueBase)null, Array.Empty<object>()));
			uiOption6Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Sixth Option Select"), new KeyboardShortcut((KeyCode)54, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the sixth, or middle-right, option in the Soul Links UI menu. By default this is Numrow 6.\n\nOOO\nOOX\nOOO", (AcceptableValueBase)null, Array.Empty<object>()));
			uiOption7Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Seventh Option Select"), new KeyboardShortcut((KeyCode)55, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the seventh, or bottom-left, option in the Soul Links UI menu. By default this is Numrow 7.\n\nOOO\nOOO\nXOO", (AcceptableValueBase)null, Array.Empty<object>()));
			uiOption8Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Eighth Option Select"), new KeyboardShortcut((KeyCode)56, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the eighth, or bottom-center, option in the Soul Links UI menu. By default this is Numrow 8.\n\nOOO\nOOO\nOXO", (AcceptableValueBase)null, Array.Empty<object>()));
			uiOption9Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Ninth Option Select"), new KeyboardShortcut((KeyCode)57, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to select the ninth, or bottom-right, option in the Soul Links UI menu. By default this is Numrow 9.\n\nOOO\nOOO\nOOX", (AcceptableValueBase)null, Array.Empty<object>()));
			uiPagingKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(new ConfigDefinition(text2, "Page Toggle Key"), new KeyboardShortcut((KeyCode)48, Array.Empty<KeyCode>()), new ConfigDescription("The keybind used to toggle the page selection in the Soul Links UI menu. By default this is Numrow 0.", (AcceptableValueBase)null, Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption1Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption2Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption3Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption4Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption5Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption6Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption7Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption8Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiOption9Key));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(uiPagingKey));
		}

		private void ManageCustomHUD()
		{
			if (Application.isPlaying)
			{
				if (Input.GetKeyDown((KeyCode)112))
				{
					SoulLinkPanel.Toggle();
				}
				if (!hudInitialized)
				{
					hudInitialized = true;
					GameObject val = GameObject.Find("HUDSimple(Clone)");
					Transform val2 = val.transform.Find("MainContainer");
					Transform val3 = val2.Find("MainUIArea");
					((Component)val3).gameObject.SetActive(true);
					Transform val4 = val3.Find("SpringCanvas");
					Transform val5 = val4.Find("UpperRightCluster");
					SoulLinkPanel soulLinkPanel = SoulLinkPanel.CreateUI(val5);
					Object.Instantiate<SoulLinkPanel>(soulLinkPanel, val5);
					SoulLinkPanel.Show();
				}
			}
		}

		private void DebugSpawnItem(ItemDef itemDef, KeyCode keyTrigger)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(keyTrigger))
			{
				Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
				Log.Info($"Player pressed {keyTrigger}. Spawning our custom item {((Object)itemDef).name} at coordinates {transform.position}");
				PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(itemDef.itemIndex), transform.position, transform.forward * 20f);
			}
		}

		private void DebugSpawnEquipment(EquipmentDef equipDef, KeyCode keyTrigger)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_006a: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(keyTrigger))
			{
				Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
				Log.Info($"Player pressed {keyTrigger}. Spawning our custom equipment {((Object)equipDef).name} at coordinates {transform.position}");
				PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(equipDef.equipmentIndex), transform.position, transform.forward * 20f);
			}
		}

		public static KeyCode GetPagingKey()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			//IL_0013: 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)
			KeyboardShortcut value = uiPagingKey.Value;
			return ((KeyboardShortcut)(ref value)).MainKey;
		}

		public static KeyCode[] GetOptionKeys()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected I4, but got Unknown
			//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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected I4, but got Unknown
			//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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected I4, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected I4, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected I4, but got Unknown
			//IL_008d: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected I4, but got Unknown
			//IL_00a2: 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)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected I4, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected I4, but got Unknown
			KeyCode[] array = new KeyCode[9];
			KeyboardShortcut value = uiOption1Key.Value;
			array[0] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			value = uiOption2Key.Value;
			array[1] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			value = uiOption3Key.Value;
			array[2] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			value = uiOption4Key.Value;
			array[3] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			value = uiOption5Key.Value;
			array[4] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			value = uiOption6Key.Value;
			array[5] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			value = uiOption7Key.Value;
			array[6] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			value = uiOption8Key.Value;
			array[7] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			value = uiOption9Key.Value;
			array[8] = (KeyCode)(int)((KeyboardShortcut)(ref value)).MainKey;
			return (KeyCode[])(object)array;
		}

		public static bool IsConfigLunar()
		{
			return isLunarEquip.Value;
		}

		public static float GetCustomCooldown()
		{
			return customCooldown.Value;
		}

		public static bool IsRandomBond()
		{
			return useRandomBond.Value;
		}

		public static bool IsHereticAllowed()
		{
			return allowHeretic.Value;
		}
	}
}
namespace SoulLink.Util
{
	public static class AssetUtil
	{
		public static AssetBundle bundle;

		public const string bundleName = "soullinkassets";

		public static Sprite defaultSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();

		public static GameObject defaultModel = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();

		public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(SoulLink.SavedInfo.Location), "soullinkassets");

		public static void Init()
		{
			bundle = AssetBundle.LoadFromFile(AssetBundlePath);
		}

		private static T SafeLoad<T>(string fileName) where T : Object
		{
			try
			{
				T val = bundle.LoadAsset<T>(fileName);
				if ((Object)(object)val == (Object)null)
				{
					Log.Debug("Asset " + fileName + " not found in the AssetBundle. Using fallback asset.");
				}
				return val;
			}
			catch (Exception ex)
			{
				Log.Error("Error loading asset " + fileName + ": " + ex.Message + "\n" + ex.StackTrace);
				return default(T);
			}
		}

		public static Sprite LoadSprite(string filename)
		{
			if (!filename.Contains("."))
			{
				filename += ".png";
			}
			return SafeLoad<Sprite>(filename) ?? defaultSprite;
		}

		public static GameObject LoadModel(string filename)
		{
			if (!filename.Contains("."))
			{
				filename += ".prefab";
			}
			return AddLogbookComponents(SafeLoad<GameObject>(filename)) ?? defaultModel;
		}

		public static Sprite LoadBaseGameSprite(string path)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<Sprite>((object)path).WaitForCompletion();
		}

		public static Texture2D LoadBaseGameTexture(string path)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<Texture2D>((object)path).WaitForCompletion();
		}

		public static GameObject LoadBaseGameModel(string path)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)path).WaitForCompletion();
		}

		public static GameObject AddLogbookComponents(GameObject itemModel)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)itemModel.GetComponent<ModelPanelParameters>() != (Object)null)
			{
				return itemModel;
			}
			GameObject val = new GameObject("Focus");
			val.transform.parent = itemModel.transform;
			MeshRenderer val2 = itemModel.GetComponentsInChildren<MeshRenderer>().ToList().OrderByDescending(delegate(MeshRenderer x)
			{
				//IL_0001: 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_0009: Unknown result type (might be due to invalid IL or missing references)
				Bounds bounds2 = ((Renderer)x).bounds;
				return SumVectorDims(((Bounds)(ref bounds2)).size);
			})
				.First();
			val.transform.parent = itemModel.transform;
			Transform transform = val.transform;
			Bounds bounds = ((Renderer)val2).bounds;
			transform.position = ((Bounds)(ref bounds)).center;
			GameObject val3 = new GameObject("Camera");
			val3.transform.parent = itemModel.transform;
			val3.transform.parent = itemModel.transform;
			val3.transform.localPosition = val.transform.position;
			ModelPanelParameters val4 = itemModel.AddComponent<ModelPanelParameters>();
			val4.focusPointTransform = val.transform;
			val4.cameraPositionTransform = val3.transform;
			bounds = ((Renderer)val2).bounds;
			val4.minDistance = 0.1f * SumVectorDims(((Bounds)(ref bounds)).size);
			bounds = ((Renderer)val2).bounds;
			val4.maxDistance = 1f * SumVectorDims(((Bounds)(ref bounds)).size);
			List<Renderer> list = ((IEnumerable<Renderer>)(object)itemModel.GetComponentsInChildren<MeshRenderer>()).ToList();
			list.AddRange((IEnumerable<Renderer>)(object)itemModel.GetComponentsInChildren<SkinnedMeshRenderer>());
			RendererInfo[] array = (RendererInfo[])(object)new RendererInfo[list.Count];
			for (int i = 0; i < list.Count; i++)
			{
				array[i] = new RendererInfo
				{
					defaultMaterial = ((list[i] is SkinnedMeshRenderer) ? list[i].sharedMaterial : list[i].material),
					renderer = list[i],
					ignoreOverlays = false,
					hideOnDeath = true
				};
			}
			ItemDisplay val5 = itemModel.AddComponent<ItemDisplay>();
			val5.rendererInfos = array;
			return itemModel;
		}

		private static float SumVectorDims(Vector3 vector)
		{
			//IL_0001: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Abs(vector.x) + Mathf.Abs(vector.y) + Mathf.Abs(vector.z);
		}
	}
}
namespace SoulLink.UI
{
	internal class SoulLinkPanel : MonoBehaviour
	{
		private string lastSelectedOption;

		private readonly List<Image> selectableImages = new List<Image>();

		public int selectedOptionIndex = -1;

		public int currentPage = 0;

		private static KeyCode[] optionSelectKeybinds;

		private static KeyCode nextPageKeybind;

		public Sprite[] optionCatalogue { get; set; }

		public static void Toggle()
		{
			Transform obj = (GameObject.Find("HUDSimple(Clone)") ?? GameObject.Find("RiskUI(Clone)")).transform.Find("MainContainer").Find("MainUIArea").Find("SpringCanvas")
				.Find("SoulLinkPanel");
			GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				Object.Destroy((Object)(object)val);
			}
			else
			{
				Show();
			}
		}

		public static void Show()
		{
			Transform parent = (GameObject.Find("HUDSimple(Clone)") ?? GameObject.Find("RiskUI(Clone)")).transform.Find("MainContainer").Find("MainUIArea").Find("SpringCanvas");
			SoulLinkPanel soulLinkPanel = CreateUI(parent);
			soulLinkPanel.Render();
		}

		public void Render()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			optionSelectKeybinds = SoulLink.GetOptionKeys();
			nextPageKeybind = SoulLink.GetPagingKey();
			foreach (Transform item in ((Component)this).transform)
			{
				Transform val = item;
				if (((Object)val).name != "SoulLinkLabel")
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
			GameObject val2 = AssetUtil.LoadBaseGameModel("RoR2/Base/UI/DefaultLabel.prefab");
			GameObject val3 = Object.Instantiate<GameObject>(val2, ((Component)this).transform);
			((Object)val3).name = "SoulLinkLabel";
			RectTransform val4 = (RectTransform)val3.transform;
			((Transform)val4).localScale = new Vector3(1.5f, 1.5f, 1.5f);
			val4.pivot = new Vector2(0f, 0f);
			((Transform)val4).SetAsFirstSibling();
			val4.anchorMin = new Vector2(0.5f, 0.85f);
			val4.anchorMax = new Vector2(0.5f, 0.85f);
			HGTextMeshProUGUI component = val3.GetComponent<HGTextMeshProUGUI>();
			((TMP_Text)component).text = "Forge Your Bond";
			((Graphic)component).color = Color.white;
			((TMP_Text)component).fontSize = 25f;
			((TMP_Text)component).alignment = (TextAlignmentOptions)514;
			Log.Debug($"Loading pageSprites. optionCatalogue.Length {optionCatalogue.Length}");
			Sprite[] pageSprites = GetPageSprites(optionCatalogue, currentPage);
			Log.Debug($"pageSprites Loaded. pageSprites.Length {pageSprites.Length}");
			Vector2 val5 = CreateImageGrid(pageSprites);
			Log.Debug("Render: Image Grid Created");
			RectTransform component2 = ((Component)this).GetComponent<RectTransform>();
			float num = Math.Max(val5.x, val5.y);
			component2.sizeDelta = new Vector2(num * 1.25f, num * 1.45f);
			Log.Debug("Render: BG Image resized");
			((Transform)val4).SetParent(((Component)component2).transform);
		}

		private Vector2 CreateImageGrid(Sprite[] imageSprites)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00fd: 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_014a: 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_0178: 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_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			if (imageSprites == null || imageSprites.Length == 0)
			{
				Debug.LogWarning((object)"No images provided.");
				return new Vector2(0f, 0f);
			}
			GameObject val = new GameObject("WindowContainer", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(((Component)this).transform, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = Vector2.zero;
			GameObject val2 = new GameObject("ImageGrid", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(val.transform, false);
			GridLayoutGroup val3 = val2.AddComponent<GridLayoutGroup>();
			val3.cellSize = new Vector2(90f, 110f);
			val3.spacing = new Vector2(10f, 10f);
			val3.constraint = (Constraint)1;
			val3.constraintCount = 3;
			((LayoutGroup)val3).childAlignment = (TextAnchor)4;
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.5f, 0.5f);
			component2.anchorMax = new Vector2(0.5f, 0.5f);
			component2.pivot = new Vector2(0.5f, 0.5f);
			for (int i = 0; i < imageSprites.Length; i++)
			{
				CreateImage(val2.transform, imageSprites[i], i);
			}
			int num = Mathf.Min(3, Mathf.CeilToInt((float)imageSprites.Length / 3f));
			float num2 = (float)num * (val3.cellSize.y + val3.spacing.y) + 20f;
			float num3 = 3f * (val3.cellSize.x + val3.spacing.x) + 20f;
			GameObject val4 = new GameObject("KeybindLabel_NextPage");
			val4.transform.SetParent(val.transform, false);
			TextMeshProUGUI val5 = val4.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val5).text = "Press " + ((object)(KeyCode)(ref nextPageKeybind)).ToString().Replace("Alpha", "") + " for next page.";
			((TMP_Text)val5).fontSize = 22f;
			((TMP_Text)val5).alignment = (TextAlignmentOptions)514;
			RectTransform component3 = val4.GetComponent<RectTransform>();
			component3.sizeDelta = new Vector2(num3, num2);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.anchoredPosition = Vector2.zero;
			component.sizeDelta = new Vector2(num3, num2);
			return new Vector2(num3 + 20f, num2 + 20f);
		}

		private void CreateImage(Transform parent, Sprite imageSprite, int index)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ImageContainer", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			VerticalLayoutGroup val2 = val.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)val2).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)val2).spacing = 5f;
			((LayoutGroup)val2).padding = new RectOffset(0, 0, 5, 5);
			GameObject val3 = new GameObject($"Image_{index}");
			val3.transform.SetParent(val.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.sizeDelta = new Vector2(75f, 75f);
			Image val5 = val3.AddComponent<Image>();
			val5.sprite = imageSprite;
			((Graphic)val5).color = Color.white;
			((Graphic)val5).material = null;
			val5.preserveAspect = true;
			GameObject val6 = new GameObject($"KeybindLabel_{index}");
			val6.transform.SetParent(val.transform, false);
			TextMeshProUGUI val7 = val6.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val7).text = ((object)(KeyCode)(ref optionSelectKeybinds[index])).ToString().Replace("Alpha", "");
			((TMP_Text)val7).fontSize = 22f;
			((TMP_Text)val7).alignment = (TextAlignmentOptions)514;
			RectTransform component = val6.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(75f, 50f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = Vector2.zero;
			selectableImages.Add(val5);
		}

		private void Update()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (selectableImages.Count == 0)
			{
				return;
			}
			for (int i = 0; i < Mathf.Min(9, selectableImages.Count); i++)
			{
				if (Input.GetKeyDown(optionSelectKeybinds[i]))
				{
					OnImageSelected(i);
				}
			}
			if (Input.GetKeyDown(nextPageKeybind))
			{
				int num = Mathf.CeilToInt((float)optionCatalogue.Length / 9f);
				Log.Debug($"Key pressed: currentPage {currentPage}, maxPages {num}, selectableImages.Count {selectableImages.Count}. Rendering.");
				currentPage++;
				if (currentPage >= num)
				{
					currentPage = 0;
				}
				selectableImages.Clear();
				Log.Debug($"Page calculated: currentPage {currentPage}, maxPages {num}, selectableImages.Count {selectableImages.Count}. Rendering.");
				Render();
			}
		}

		private void OnImageSelected(int index)
		{
			if (index >= 0 && index < selectableImages.Count)
			{
				selectedOptionIndex = index;
				lastSelectedOption = $"Option {index}";
				Debug.Log((object)("Selected: " + lastSelectedOption));
			}
		}

		public static SoulLinkPanel CreateUI(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("SoulLinkPanel");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(400f, 300f);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = Color.white;
			Sprite val4 = AssetUtil.LoadSprite("SoulLinkMenuUI.png");
			if (Object.op_Implicit((Object)(object)val4))
			{
				Vector4 border = val4.border;
				((Vector4)(ref border)).Set(40f, 55f, 40f, 55f);
				val3.sprite = val4;
				val3.type = (Type)1;
				((Graphic)val3).material = null;
			}
			else
			{
				Debug.LogWarning((object)"Failed to load rounded corner sprite.");
			}
			return val.AddComponent<SoulLinkPanel>();
		}

		private Sprite[] GetPageSprites(Sprite[] allSprites, int page)
		{
			int num = page * 9;
			Log.Debug($"GetPageSprites: startIndex {num}, page {page}, allSprites.Length {allSprites.Length}");
			if (num >= allSprites.Length)
			{
				return allSprites.Take(9).ToArray();
			}
			return allSprites.Skip(num).Take(9).ToArray();
		}

		private Sprite[] LoadExampleSprites()
		{
			return (Sprite[])(object)new Sprite[11]
			{
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/Bandit2/texBanditIcon.png")),
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/Brother/texBrotherIcon.png")),
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/Captain/texCaptainIcon.png")),
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/Engi/texEngiIcon.png")),
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/Heretic/texHereticIcon.png")),
				AssetUtil.LoadBaseGameSprite("RoR2/Base/Common/texSurvivorBGIcon.png"),
				AssetUtil.LoadBaseGameSprite("RoR2/Base/Bear/texBearIcon.png"),
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/ArtifactShell/texUnidentifiedKillerIcon.png")),
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/Mage/texMageIcon.png")),
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/Commando/texCommandoIcon.png")),
				ConvertTextureToSprite(AssetUtil.LoadBaseGameTexture("RoR2/Base/Merc/texMercIcon.png"))
			};
		}

		public static Sprite ConvertTextureToSprite(Texture2D texture)
		{
			//IL_0035: 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)
			if ((Object)(object)texture == (Object)null)
			{
				Debug.LogError((object)"ConvertTextureToSprite received a null texture!");
				return null;
			}
			return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f));
		}

		static SoulLinkPanel()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			KeyCode[] array = new KeyCode[9];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			optionSelectKeybinds = (KeyCode[])(object)array;
			nextPageKeybind = (KeyCode)48;
		}
	}
}
namespace SoulLink.Items
{
	internal class SoulLinkEquip
	{
		public class SoulLinkEquipBehavior : ItemBehavior
		{
			public bool activated = false;

			public bool firstTimeUse = true;

			public CharacterBody chosenBodyTarget;

			private SoulLinkPanel menu;

			private bool wasJustRespawned = false;

			private float healthBeforeTransform;

			private List<(BuffIndex, int)> starterBuffs;

			public SurvivorDef[] TransformTargetOptions { get; set; }

			[ItemDefAssociation(useOnServer = true, useOnClient = false)]
			public static EquipmentDef GetEquipDef()
			{
				return equipDef;
			}

			private void onEnable()
			{
			}

			private void Start()
			{
			}

			private void FixedUpdate()
			{
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_041b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0426: Unknown result type (might be due to invalid IL or missing references)
				//IL_0429: Unknown result type (might be due to invalid IL or missing references)
				//IL_042e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0433: Unknown result type (might be due to invalid IL or missing references)
				//IL_0436: Unknown result type (might be due to invalid IL or missing references)
				//IL_043b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0444: Expected O, but got Unknown
				//IL_023c: Unknown result type (might be due to invalid IL or missing references)
				//IL_023f: 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)
				//IL_047f: Unknown result type (might be due to invalid IL or missing references)
				if (activated)
				{
					if ((Object)(object)chosenBodyTarget == (Object)null && (SoulLink.IsRandomBond() || !base.body.isPlayerControlled))
					{
						firstTimeUse = false;
						chosenBodyTarget = GetBodyFromSurvivorDef(TransformTargetOptions[Random.RandomRangeInt(0, TransformTargetOptions.Length)]);
						BroadcastBondedChatMessage(base.body, chosenBodyTarget);
					}
					if (firstTimeUse)
					{
						Log.Debug("SoulLinkEquip: First time use!");
						if ((Object)(object)menu == (Object)null)
						{
							GameObject val = GameObject.Find("HUDSimple(Clone)");
							Transform val2 = val.transform.Find("MainContainer");
							Transform val3 = val2.Find("MainUIArea");
							((Component)val3).gameObject.SetActive(true);
							menu = SoulLinkPanel.CreateUI(val3);
							menu.optionCatalogue = GetTargetImages(TransformTargetOptions);
							menu.Render();
							Log.Debug("Menu Initialized in Behavior");
						}
						firstTimeUse = false;
					}
					else
					{
						Log.Debug("SoulLinkEquip: NOT first time use!");
						if (Object.op_Implicit((Object)(object)chosenBodyTarget))
						{
							CharacterBody val4 = BodyCatalog.bodyPrefabBodyComponents.Where((CharacterBody searchBody) => searchBody.bodyIndex == base.body.bodyIndex).FirstOrDefault();
							base.body.master.bodyPrefab = BodyCatalog.GetBodyPrefab(chosenBodyTarget.bodyIndex);
							CharacterBody val5 = base.body.master.Respawn(base.body.master.GetBody().transform.position + new Vector3(0f, 5f, 0f), base.body.master.GetBody().transform.rotation, false);
							SoulLinkEquipBehavior soulLinkEquipBehavior = val5.AddItemBehavior<SoulLinkEquipBehavior>(1);
							soulLinkEquipBehavior.firstTimeUse = false;
							soulLinkEquipBehavior.chosenBodyTarget = val4;
							soulLinkEquipBehavior.wasJustRespawned = true;
							soulLinkEquipBehavior.healthBeforeTransform = base.body.healthComponent.health;
							List<(BuffIndex, int)> list = new List<(BuffIndex, int)>();
							BuffIndex[] activeBuffsList = base.body.activeBuffsList;
							foreach (BuffIndex val6 in activeBuffsList)
							{
								BuffDef buffDef = BuffCatalog.GetBuffDef(val6);
								if (buffsToTransfer.Contains(((Object)buffDef).name))
								{
									list.Add((buffDef.buffIndex, base.body.GetBuffCount(buffDef)));
								}
							}
							soulLinkEquipBehavior.starterBuffs = list;
							Log.Debug("Transforming! originalBody: " + ((Object)val4).name + ", newBody: " + ((Object)val5).name);
						}
						else
						{
							Log.Debug("No chosenBodyTarget detected on current body " + ((Object)base.body).name);
							firstTimeUse = true;
						}
					}
					activated = false;
				}
				if (Object.op_Implicit((Object)(object)menu) && menu.selectedOptionIndex >= 0 && (Object)(object)chosenBodyTarget == (Object)null)
				{
					int num = menu.currentPage * 9 + menu.selectedOptionIndex;
					chosenBodyTarget = GetBodyFromSurvivorDef(TransformTargetOptions[num]);
					Log.Debug($"chosenBodyTarget picked! selectedIndex {num}, menu.selectedOptionIndex {menu.selectedOptionIndex}, chosenBodyTarget.name {((Object)chosenBodyTarget).name}");
					Object.Destroy((Object)(object)((Component)menu).gameObject);
					base.body.inventory.DeductActiveEquipmentCooldown(equipDef.cooldown * 3f / 4f);
					BroadcastBondedChatMessage(base.body, chosenBodyTarget);
				}
				if (!wasJustRespawned || !NetworkServer.active)
				{
					return;
				}
				DamageInfo val7 = new DamageInfo
				{
					position = ((Component)this).transform.position,
					damage = base.body.healthComponent.combinedHealth - healthBeforeTransform,
					procCoefficient = 0f,
					damageType = DamageTypeCombo.op_Implicit((DamageType)67),
					damageColorIndex = (DamageColorIndex)13,
					attacker = null
				};
				base.body.healthComponent.TakeDamage(val7);
				foreach (var starterBuff in starterBuffs)
				{
					for (int j = 0; j < starterBuff.Item2; j++)
					{
						base.body.AddBuff(BuffCatalog.GetBuffDef(starterBuff.Item1));
					}
				}
				wasJustRespawned = false;
			}

			private static CharacterBody GetBodyFromSurvivorDef(SurvivorDef survivorDef)
			{
				return BodyCatalog.bodyPrefabBodyComponents.Where((CharacterBody bodyDef) => bodyDef.bodyIndex == SurvivorCatalog.GetBodyIndexFromSurvivorIndex(survivorDef.survivorIndex)).ToArray().FirstOrDefault();
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnInventoryChanged <>9__8_0;

			public static hook_PerformEquipmentAction <>9__8_1;

			public static Func<SurvivorDef, bool> <>9__10_0;

			internal void <Hooks>b__8_0(orig_OnInventoryChanged orig, CharacterBody body)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(body);
				if ((Object)(object)((Component)body).GetComponent<SoulLinkEquipBehavior>() == (Object)null)
				{
					body.AddItemBehavior<SoulLinkEquipBehavior>(((Object)(object)body.inventory.GetEquipment((uint)body.inventory.activeEquipmentSlot).equipmentDef == (Object)(object)equipDef) ? 1 : 0);
					return;
				}
				bool flag = false;
				EquipmentState[] equipmentStateSlots = body.inventory.equipmentStateSlots;
				foreach (EquipmentState val in equipmentStateSlots)
				{
					if ((Object)(object)val.equipmentDef == (Object)(object)equipDef)
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					SoulLinkEquipBehavior component = ((Component)body).GetComponent<SoulLinkEquipBehavior>();
					component.firstTimeUse = true;
					component.chosenBodyTarget = null;
				}
			}

			internal bool <Hooks>b__8_1(orig_PerformEquipmentAction orig, EquipmentSlot slot, EquipmentDef currentEquipDef)
			{
				Log.Debug("SoulLinkEquip: Action performed.");
				if ((Object)(object)currentEquipDef == (Object)(object)equipDef)
				{
					if (!Object.op_Implicit((Object)(object)slot.characterBody))
					{
						return false;
					}
					SoulLinkEquipBehavior component = ((Component)slot.characterBody).GetComponent<SoulLinkEquipBehavior>();
					if (Object.op_Implicit((Object)(object)component))
					{
						if (component.TransformTargetOptions == null)
						{
							SearchForSurvivorDefs();
							component.TransformTargetOptions = validTransformTargets;
						}
						component.activated = true;
					}
					return true;
				}
				return orig.Invoke(slot, currentEquipDef);
			}

			internal bool <SearchForSurvivorDefs>b__10_0(SurvivorDef survivorDef)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				return SurvivorCatalog.SurvivorIsUnlockedOnThisClient(survivorDef.survivorIndex) && survivorDef.CheckRequiredExpansionEnabled((NetworkUser)null) && (SoulLink.IsHereticAllowed() || ((Object)survivorDef.bodyPrefab).name != "HereticBody") && survivorDef.CheckUserHasRequiredEntitlement(((MPEventSystem)EventSystem.current).localUser);
			}
		}

		public static EquipmentDef equipDef;

		private static string itemId = "SoulLink";

		private static SurvivorDef[] validTransformTargets;

		private static readonly string chatMessage = "<style=cHumanObjective>{user}</style><style=cEvent> has bound their soul to </style><style=cWorldEvent>{target}</style>";

		private static readonly string[] buffsToTransfer = new string[8] { "bdPermanentCurse", "bdPermanentDebuff", "bdSoulCost", "bdExtraLifeBuff", "bdFreeUnlock", "bdBanditSkull", "bdChakraBuff", "bdRevitalizeBuff" };

		internal static void Init()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			GenerateItem();
			AddTokens();
			ItemDisplayRuleDict val = CreateDisplayRules();
			ItemAPI.Add(new CustomEquipment(equipDef, val));
			Hooks();
		}

		private static void GenerateItem()
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			equipDef = ScriptableObject.CreateInstance<EquipmentDef>();
			itemId = itemId.Replace(" ", "").ToUpper();
			((Object)equipDef).name = itemId;
			equipDef.nameToken = itemId + "_NAME";
			equipDef.pickupToken = itemId + "_PICKUP";
			equipDef.descriptionToken = itemId + "_DESCRIPTION";
			equipDef.loreToken = itemId + "_LORE";
			equipDef.pickupModelPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab");
			equipDef.canBeRandomlyTriggered = false;
			equipDef.canDrop = true;
			equipDef.cooldown = SoulLink.GetCustomCooldown();
			if (SoulLink.IsConfigLunar())
			{
				equipDef.pickupIconSprite = AssetUtil.LoadSprite("SoulLinkIcon_Lunar.png");
				equipDef.isLunar = true;
				equipDef.colorIndex = (ColorIndex)4;
			}
			else
			{
				equipDef.pickupIconSprite = AssetUtil.LoadSprite("SoulLinkIcon.png");
				equipDef.isLunar = false;
				equipDef.colorIndex = (ColorIndex)5;
			}
		}

		private static ItemDisplayRuleDict CreateDisplayRules()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: 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_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_0668: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_0688: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: 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_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0700: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0720: Unknown result type (might be due to invalid IL or missing references)
			//IL_0721: Unknown result type (might be due to invalid IL or missing references)
			//IL_073c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: 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_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_0798: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0810: Unknown result type (might be due to invalid IL or missing references)
			//IL_0815: 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_0846: Unknown result type (might be due to invalid IL or missing references)
			//IL_084b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0850: Unknown result type (might be due to invalid IL or missing references)
			//IL_0851: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c3: 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_08de: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e3: 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_08e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0904: 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_0940: Unknown result type (might be due to invalid IL or missing references)
			//IL_0945: Unknown result type (might be due to invalid IL or missing references)
			//IL_095b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0960: Unknown result type (might be due to invalid IL or missing references)
			//IL_0976: Unknown result type (might be due to invalid IL or missing references)
			//IL_097b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0980: Unknown result type (might be due to invalid IL or missing references)
			//IL_0981: Unknown result type (might be due to invalid IL or missing references)
			//IL_099c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dd: 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_09f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a34: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab1: Unknown result type (might be due to invalid IL or missing references)
			ItemDisplayRuleDict val = new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
			val.Add("EquipmentDroneBody", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "GunBarrelBase",
					localPos = new Vector3(-0.2f, 0f, 2.1f),
					localAngles = new Vector3(90f, 0f, 0f),
					localScale = new Vector3(0.4f, 0.4f, 0.4f)
				}
			});
			val.Add("mdlCommandoDualies", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Pelvis",
					localPos = new Vector3(0.15965f, -0.10945f, -0.13692f),
					localAngles = new Vector3(314.421f, 130.9908f, 201.2805f),
					localScale = new Vector3(0.06134f, 0.03805f, 0.06134f)
				}
			});
			val.Add("mdlHuntress", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "BowHinge1L",
					localPos = new Vector3(0.16519f, 0.04391f, 0.04425f),
					localAngles = new Vector3(344.6824f, 320.9641f, 240.9161f),
					localScale = new Vector3(0.06956f, 0.06956f, 0.06956f)
				}
			});
			val.Add("mdlBandit2", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Stomach",
					localPos = new Vector3(0.21794f, 0.03553f, 0.09086f),
					localAngles = new Vector3(11.73269f, 130.9432f, 323.907f),
					localScale = new Vector3(0.06571f, 0.06571f, 0.06571f)
				}
			});
			val.Add("mdlToolbot", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Neck",
					localPos = new Vector3(0.21707f, 1.58903f, 0.35364f),
					localAngles = new Vector3(346.6717f, 315.2442f, 295.8514f),
					localScale = new Vector3(0.59539f, 0.59539f, 0.59539f)
				}
			});
			val.Add("mdlEngi", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Chest",
					localPos = new Vector3(0.02309f, -0.11628f, -0.29646f),
					localAngles = new Vector3(343.5479f, 128.2443f, 32.49729f),
					localScale = new Vector3(0.08699f, 0.08699f, 0.08699f)
				}
			});
			val.Add("mdlMage", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "UpperArmR",
					localPos = new Vector3(-0.12986f, 0.1991f, -0.04129f),
					localAngles = new Vector3(347.4306f, 345.6252f, 85.64943f),
					localScale = new Vector3(0.08238f, 0.08238f, 0.08238f)
				}
			});
			val.Add("mdlMerc", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "HandL",
					localPos = new Vector3(-0.09109f, 0.0813f, -0.03169f),
					localAngles = new Vector3(21.70813f, 323.4272f, 49.0989f),
					localScale = new Vector3(0.08252f, 0.08394f, 0.07476f)
				}
			});
			val.Add("mdlTreebot", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "WeaponPlatform",
					localPos = new Vector3(0.26516f, -0.35155f, 0.48567f),
					localAngles = new Vector3(348.9675f, 351.5085f, 73.60771f),
					localScale = new Vector3(0.24464f, 0.13364f, 0.13364f)
				}
			});
			val.Add("mdlLoader", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Chest",
					localPos = new Vector3(0.35216f, 0.49106f, 0.23169f),
					localAngles = new Vector3(350.0082f, 312.9914f, 285.678f),
					localScale = new Vector3(91f / (345f * MathF.PI), 0.06583f, 91f / (345f * MathF.PI))
				}
			});
			val.Add("mdlCroco", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Head",
					localPos = new Vector3(-2.05468f, 1.85249f, -3.67751f),
					localAngles = new Vector3(15.07537f, 324.9648f, 73.08989f),
					localScale = new Vector3(-1.77162f, 2.20423f, 2.53584f)
				}
			});
			val.Add("mdlCaptain", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "HandL",
					localPos = new Vector3(-0.05515f, -0.11752f, -0.01267f),
					localAngles = new Vector3(290.4974f, 312.2321f, 331.4503f),
					localScale = new Vector3(0.1f, 0.1f, 0.1f)
				}
			});
			val.Add("mdlRailGunner", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "GunRoot",
					localPos = new Vector3(-0.01791f, 1E-05f, -0.36122f),
					localAngles = new Vector3(6E-05f, 78.96882f, 271.9931f),
					localScale = new Vector3(0.05038f, 0.05038f, 0.05038f)
				}
			});
			val.Add("mdlVoidSurvivor", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Hand",
					localPos = new Vector3(-0.01978f, -0.03643f, -0.01855f),
					localAngles = new Vector3(55.10281f, 68.31735f, 76.12302f),
					localScale = new Vector3(0.1f, 0.1f, 0.1f)
				}
			});
			val.Add("mdlSeeker", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Pack",
					localPos = new Vector3(0.08363f, 0.17586f, -0.34696f),
					localAngles = new Vector3(347.5371f, 236.0009f, 99.67917f),
					localScale = new Vector3(0.1f, 0.1f, 0.1f)
				}
			});
			val.Add("mdlFalseSon", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "LowerArmL",
					localPos = new Vector3(-0.00107f, 0.06443f, -0.04812f),
					localAngles = new Vector3(285.4764f, 342.4372f, 287.4732f),
					localScale = new Vector3(0.20777f, 0.11744f, 0.14546f)
				}
			});
			val.Add("mdlChef", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "Head",
					localPos = new Vector3(0.03178f, 0.16548f, 0.25901f),
					localAngles = new Vector3(327.3342f, 168.3224f, 3.33605f),
					localScale = new Vector3(0.11638f, 0.17782f, 0.22501f)
				}
			});
			val.Add("mdlScav", (ItemDisplayRule[])(object)new ItemDisplayRule[1]
			{
				new ItemDisplayRule
				{
					ruleType = (ItemDisplayRuleType)0,
					followerPrefab = AssetUtil.LoadModel("SoulLinkModel.prefab"),
					childName = "MuzzleEnergyCannon",
					localPos = new Vector3(7.05081f, 3.682f, -5.10893f),
					localAngles = new Vector3(352.1646f, 347.9308f, 280.7483f),
					localScale = new Vector3(2.4235f, 1.67428f, 2.85059f)
				}
			});
			return val;
		}

		public static void Hooks()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			object obj = <>c.<>9__8_0;
			if (obj == null)
			{
				hook_OnInventoryChanged val = delegate(orig_OnInventoryChanged orig, CharacterBody body)
				{
					//IL_002c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0065: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Unknown result type (might be due to invalid IL or missing references)
					//IL_006d: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(body);
					if ((Object)(object)((Component)body).GetComponent<SoulLinkEquipBehavior>() == (Object)null)
					{
						body.AddItemBehavior<SoulLinkEquipBehavior>(((Object)(object)body.inventory.GetEquipment((uint)body.inventory.activeEquipmentSlot).equipmentDef == (Object)(object)equipDef) ? 1 : 0);
					}
					else
					{
						bool flag = false;
						EquipmentState[] equipmentStateSlots = body.inventory.equipmentStateSlots;
						foreach (EquipmentState val3 in equipmentStateSlots)
						{
							if ((Object)(object)val3.equipmentDef == (Object)(object)equipDef)
							{
								flag = true;
								break;
							}
						}
						if (!flag)
						{
							SoulLinkEquipBehavior component2 = ((Component)body).GetComponent<SoulLinkEquipBehavior>();
							component2.firstTimeUse = true;
							component2.chosenBodyTarget = null;
						}
					}
				};
				<>c.<>9__8_0 = val;
				obj = (object)val;
			}
			CharacterBody.OnInventoryChanged += (hook_OnInventoryChanged)obj;
			object obj2 = <>c.<>9__8_1;
			if (obj2 == null)
			{
				hook_PerformEquipmentAction val2 = delegate(orig_PerformEquipmentAction orig, EquipmentSlot slot, EquipmentDef currentEquipDef)
				{
					Log.Debug("SoulLinkEquip: Action performed.");
					if ((Object)(object)currentEquipDef == (Object)(object)equipDef)
					{
						if (!Object.op_Implicit((Object)(object)slot.characterBody))
						{
							return false;
						}
						SoulLinkEquipBehavior component = ((Component)slot.characterBody).GetComponent<SoulLinkEquipBehavior>();
						if (Object.op_Implicit((Object)(object)component))
						{
							if (component.TransformTargetOptions == null)
							{
								SearchForSurvivorDefs();
								component.TransformTargetOptions = validTransformTargets;
							}
							component.activated = true;
						}
						return true;
					}
					return orig.Invoke(slot, currentEquipDef);
				};
				<>c.<>9__8_1 = val2;
				obj2 = (object)val2;
			}
			EquipmentSlot.PerformEquipmentAction += (hook_PerformEquipmentAction)obj2;
		}

		private static void AddTokens()
		{
			LanguageAPI.Add(itemId ?? "", "Soul Links");
			LanguageAPI.Add(itemId + "_NAME", "Soul Links");
			LanguageAPI.Add(itemId + "_PICKUP", "Transform into another Survivor at will.");
			LanguageAPI.Add(itemId + "_DESCRIPTION", "<style=cHumanObjective>On use,</style> become a different survivor. <style=cHumanObjective>The first use</style> after pickup will select the survivor to bond to, then further uses will trigger <style=cArtifact>the transformation.</style>");
			string text = "Order: Soul Links\nTracking Number: 888 * ****\nEstimated Delivery: 10 / 04 / 2099\nShipping Method: Priority\nShipping Address: Pacific Proposal Park, Sole United America, Earth\nShipping Details:\n\nA rather symbollic gesture, but perhaps it will be a welcome one nonetheless. Excavation sites found these two rings forged entirely linked within one another. They are inseparable, but God knows we've tried to break it up. They seem to emit a strange, almost imperceptible, energy reading when pulled tightly together so the inner rings clash. Maybe your establishment can find a use for them.\n\nIf you don't happen to hear from me, I'll be taking some time away from the lab. Lately, I just haven't been feeling quite like myself.\n\nRegards,\nDr.Robinson...?";
			LanguageAPI.Add(itemId + "_LORE", text);
		}

		private static void SearchForSurvivorDefs()
		{
			validTransformTargets = SurvivorCatalog.orderedSurvivorDefs.Where((SurvivorDef survivorDef) => SurvivorCatalog.SurvivorIsUnlockedOnThisClient(survivorDef.survivorIndex) && survivorDef.CheckRequiredExpansionEnabled((NetworkUser)null) && (SoulLink.IsHereticAllowed() || ((Object)survivorDef.bodyPrefab).name != "HereticBody") && survivorDef.CheckUserHasRequiredEntitlement(((MPEventSystem)EventSystem.current).localUser)).ToArray();
			Log.Debug($"validTransformTargets set with {validTransformTargets.Length} as its length");
		}

		private static void BroadcastBondedChatMessage(CharacterBody userBody, CharacterBody targetBody)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected I4, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			string text = chatMessage.Replace("{target}", targetBody.GetDisplayName());
			TeamIndex teamIndex = userBody.master.teamIndex;
			TeamIndex val = teamIndex;
			switch ((int)val)
			{
			case 2:
				text = text.Replace("cHumanObjective", "cDeath");
				break;
			case 4:
				text = text.Replace("cHumanObjective", "cIsVoid");
				break;
			case 3:
				text = text.Replace("cHumanObjective", "cLunarObjective");
				break;
			case 0:
				text = text.Replace("cHumanObjective", "cArtifact");
				break;
			case 1:
				if (!userBody.isPlayerControlled)
				{
					text = text.Replace("<style=cHumanObjective>{user}</style>", "<color=#" + ColorCatalog.GetColorHexString((ColorIndex)5) + ">{user}</color>");
				}
				break;
			}
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = text.Replace("{user}", userBody.isPlayerControlled ? userBody.master.playerCharacterMasterController.networkUser.userName : userBody.GetDisplayName())
			});
		}

		private static Sprite[] GetTargetImages(SurvivorDef[] survivorDefs)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			List<Sprite> list = new List<Sprite>();
			foreach (SurvivorDef val in survivorDefs)
			{
				Texture survivorPortrait = SurvivorCatalog.GetSurvivorPortrait(val.survivorIndex);
				list.Add(SoulLinkPanel.ConvertTextureToSprite((Texture2D)(object)((survivorPortrait is Texture2D) ? survivorPortrait : null)));
			}
			Log.Debug($"GetTargetImages: Returning {list.Count} sprites from {survivorDefs.Length} survivorDefs");
			return list.ToArray();
		}
	}
}