Decompiled source of Obeliskial Essentials v1.3.0

BepInEx/patchers/BepInExConfigManager.Mono.Patcher.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Mono.Cecil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BepInExConfigManager.Patcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BepInExConfigManager.Patcher")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("beabe9b7-0c1c-4071-a99c-1ced983287e9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class Patcher
{
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class ConfigFile_ctor
	{
		internal static void Postfix(ConfigFile __instance, BepInPlugin ownerMetadata)
		{
			CachedConfigFile cachedConfigFile = new CachedConfigFile(__instance, ownerMetadata);
			ConfigFiles.Add(cachedConfigFile);
			ConfigFileCreated?.Invoke(cachedConfigFile);
		}
	}

	internal const string GUID = "com.sinai.bepinexconfigmanager.patcher";

	public static Action<CachedConfigFile> ConfigFileCreated;

	public static List<CachedConfigFile> ConfigFiles { get; }

	public static IEnumerable<string> TargetDLLs { get; }

	public static void Patch(AssemblyDefinition _)
	{
	}

	static Patcher()
	{
		ConfigFiles = new List<CachedConfigFile>();
		TargetDLLs = Enumerable.Empty<string>();
		Init();
	}

	internal static void Init()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("com.sinai.bepinexconfigmanager.patcher").PatchAll();
	}
}
public class CachedConfigFile
{
	public readonly ConfigFile configFile;

	public readonly BepInPlugin metadata;

	public CachedConfigFile(ConfigFile configFile, BepInPlugin metadata)
	{
		this.configFile = configFile;
		this.metadata = metadata;
	}
}

BepInEx/plugins/BepInExConfigManager.Mono.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConfigManager.UI;
using ConfigManager.UI.InteractiveValues;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
using UniverseLib;
using UniverseLib.Config;
using UniverseLib.Input;
using UniverseLib.UI;
using UniverseLib.UI.Models;
using UniverseLib.UI.Panels;
using UniverseLib.UI.Widgets;
using UniverseLib.Utility;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BepInExConfigManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BepInExConfigManager")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("51308bd5-5872-4a72-85d2-6194673c8a5f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ConfigManager
{
	[BepInPlugin("com.sinai.BepInExConfigManager", "BepInExConfigManager", "1.3.0")]
	public class ConfigManager : BaseUnityPlugin
	{
		public const string GUID = "com.sinai.BepInExConfigManager";

		public const string NAME = "BepInExConfigManager";

		public const string AUTHOR = "Sinai";

		public const string VERSION = "1.3.0";

		internal const string CTG_ID = "BepInExConfigManager";

		internal static string CTG = "Settings";

		internal static ConfigEntry<KeyCode> Main_Menu_Toggle;

		internal static ConfigEntry<bool> Auto_Save_Configs;

		internal static ConfigEntry<float> Startup_Delay;

		internal static ConfigEntry<bool> Disable_EventSystem_Override;

		public static ConfigManager Instance { get; private set; }

		public static ManualLogSource LogSource => ((BaseUnityPlugin)Instance).Logger;

		internal static Harmony Harmony { get; } = new Harmony("com.sinai.BepInExConfigManager");


		internal void Awake()
		{
			Instance = this;
			Init();
		}

		internal void Update()
		{
			DoUpdate();
		}

		public static void Init()
		{
			//IL_002b: 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)
			InitConfig();
			Universe.Init(Startup_Delay.Value, (Action)LateInit, (Action<string, LogType>)LogHandler, new UniverseLibConfig
			{
				Disable_EventSystem_Override = Disable_EventSystem_Override.Value,
				Force_Unlock_Mouse = true,
				Unhollowed_Modules_Folder = Path.Combine(Paths.BepInExRootPath, "unhollowed")
			});
		}

		private static void LateInit()
		{
			UIManager.Init();
		}

		public static void DoUpdate()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (UIManager.uiBase != null && InputManager.GetKeyDown(Main_Menu_Toggle.Value))
			{
				UIManager.ShowMenu = !UIManager.ShowMenu;
			}
		}

		public static void InitConfig()
		{
			//IL_0015: 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_0035: Expected O, but got Unknown
			//IL_0035: Expected O, but got Unknown
			//IL_004e: 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: Expected O, but got Unknown
			//IL_006a: Expected O, but got Unknown
			Main_Menu_Toggle = ((BaseUnityPlugin)Instance).Config.Bind<KeyCode>(new ConfigDefinition(CTG, "Main Menu Toggle"), (KeyCode)286, new ConfigDescription("The toggle for the Config Manager menu", (AcceptableValueBase)null, new object[0]));
			Auto_Save_Configs = ((BaseUnityPlugin)Instance).Config.Bind<bool>(new ConfigDefinition(CTG, "Auto-save settings"), false, new ConfigDescription("Automatically save settings after changing them? This will mean the undo feature will be unavailable.", (AcceptableValueBase)null, new object[0]));
			Auto_Save_Configs.SettingChanged += Auto_Save_Configs_SettingChanged;
			Startup_Delay = ((BaseUnityPlugin)Instance).Config.Bind<float>(CTG, "Startup Delay", 1f, "Delays the core startup process. Adjust it if you experience issues.");
			Disable_EventSystem_Override = ((BaseUnityPlugin)Instance).Config.Bind<bool>(CTG, "Disable EventSystem Override", false, "Disables the overriding of the EventSystem from the game, if you experience issues with UI Input.");
			Disable_EventSystem_Override.SettingChanged += Disable_EventSystem_Override_SettingChanged;
		}

		private static void Disable_EventSystem_Override_SettingChanged(object sender, EventArgs e)
		{
			bool disable_EventSystem_Override = (bool)((SettingChangedEventArgs)((e is SettingChangedEventArgs) ? e : null)).ChangedSetting.BoxedValue;
			ConfigManager.Disable_EventSystem_Override = disable_EventSystem_Override;
		}

		private static void Auto_Save_Configs_SettingChanged(object sender, EventArgs e)
		{
			bool flag = (bool)((SettingChangedEventArgs)((e is SettingChangedEventArgs) ? e : null)).ChangedSetting.BoxedValue;
			((Component)UIManager.saveButton.Component).gameObject.SetActive(!flag);
		}

		private static void LogHandler(string log, LogType logType)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected I4, but got Unknown
			switch ((int)logType)
			{
			case 3:
				LogSource.LogMessage((object)log);
				break;
			case 1:
			case 2:
				LogSource.LogWarning((object)log);
				break;
			case 0:
			case 4:
				LogSource.LogError((object)log);
				break;
			}
		}
	}
}
namespace ConfigManager.UI
{
	public class CachedConfigEntry
	{
		public InteractiveValue IValue;

		public bool UIConstructed;

		public GameObject parentContent;

		public GameObject ContentGroup;

		public RectTransform ContentRect;

		public GameObject SubContentGroup;

		public Text mainLabel;

		internal GameObject UIroot;

		internal GameObject undoButton;

		public ConfigEntryBase RefConfig { get; }

		public object EditedValue { get; internal set; }

		public Type FallbackType => RefConfig.SettingType;

		public CachedConfigEntry(ConfigEntryBase config, GameObject parent)
		{
			RefConfig = config;
			parentContent = parent;
			EditedValue = config.BoxedValue;
			CreateIValue(config.BoxedValue, FallbackType);
		}

		internal void OnSettingChanged(object sender, EventArgs e)
		{
			object value = (EditedValue = ((SettingChangedEventArgs)((e is SettingChangedEventArgs) ? e : null)).ChangedSetting.BoxedValue);
			IValue.Value = value;
			IValue.OnValueUpdated();
		}

		public void CreateIValue(object value, Type fallbackType)
		{
			ConfigDescription description = RefConfig.Description;
			if (((description != null) ? description.AcceptableValues : null) != null && ((object)RefConfig.Description.AcceptableValues).GetType().Name.StartsWith("AcceptableValueList"))
			{
				Type actualType = ReflectionExtensions.GetActualType(value);
				IValue = new InteractiveValueList(value, actualType);
			}
			else
			{
				IValue = InteractiveValue.Create(value, fallbackType);
			}
			IValue.Owner = this;
			IValue.mainContentParent = ContentGroup;
			IValue.subContentParent = SubContentGroup;
		}

		public void UpdateValue()
		{
			IValue.Value = RefConfig.BoxedValue;
			EditedValue = RefConfig.BoxedValue;
			IValue.OnValueUpdated();
			IValue.RefreshSubContentState();
		}

		public void SetValueFromIValue()
		{
			if (RefConfig.Description.AcceptableValues != null)
			{
				IValue.Value = RefConfig.Description.AcceptableValues.Clamp(IValue.Value);
			}
			object editedValue = EditedValue;
			if ((editedValue == null && IValue.Value == null) || (editedValue != null && editedValue.Equals(IValue.Value)))
			{
				return;
			}
			if (ConfigManager.Auto_Save_Configs.Value)
			{
				RefConfig.BoxedValue = IValue.Value;
				if (!RefConfig.ConfigFile.SaveOnConfigSet)
				{
					RefConfig.ConfigFile.Save();
				}
				UpdateValue();
			}
			else
			{
				EditedValue = IValue.Value;
				UIManager.OnEntryEdit(this);
				undoButton.SetActive(true);
			}
		}

		public void UndoEdits()
		{
			EditedValue = RefConfig.BoxedValue;
			IValue.Value = EditedValue;
			IValue.OnValueUpdated();
			OnSaveOrUndo();
		}

		public void RevertToDefault()
		{
			RefConfig.BoxedValue = RefConfig.DefaultValue;
			UpdateValue();
			OnSaveOrUndo();
		}

		internal void OnSaveOrUndo()
		{
			undoButton.SetActive(false);
			UIManager.OnEntrySaveOrUndo(this);
		}

		public void Enable()
		{
			if (!UIConstructed)
			{
				ConstructUI();
				UpdateValue();
			}
			UIroot.SetActive(true);
			UIroot.transform.SetAsLastSibling();
		}

		public void Disable()
		{
			if (Object.op_Implicit((Object)(object)UIroot))
			{
				UIroot.SetActive(false);
			}
		}

		public void Destroy()
		{
			if (Object.op_Implicit((Object)(object)UIroot))
			{
				Object.Destroy((Object)(object)UIroot);
			}
		}

		internal void ConstructUI()
		{
			//IL_001b: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: 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_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: 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_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			UIConstructed = true;
			UIroot = UIFactory.CreateVerticalGroup(parentContent, "CacheObjectBase.MainContent", true, false, true, true, 0, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null);
			ContentRect = UIroot.GetComponent<RectTransform>();
			ContentRect.SetSizeWithCurrentAnchors((Axis)1, 25f);
			GameObject uIroot = UIroot;
			int? num = 25;
			int? num2 = 9999;
			UIFactory.SetLayoutElement(uIroot, (int?)200, num, (int?)5000, num2, (int?)null, (int?)null, (bool?)null);
			ContentGroup = UIFactory.CreateVerticalGroup(UIroot, "ConfigHolder", true, false, true, true, 5, new Vector4(2f, 2f, 5f, 5f), new Color(0.12f, 0.12f, 0.12f), (TextAnchor?)null);
			GameObject val = UIFactory.CreateHorizontalGroup(ContentGroup, "ConfigEntryHolder", false, false, true, true, 5, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)(TextAnchor)3);
			num2 = 30;
			num = 0;
			UIFactory.SetLayoutElement(val, (int?)null, num2, (int?)null, num, (int?)null, (int?)null, (bool?)null);
			mainLabel = UIFactory.CreateLabel(val, "ConfigLabel", RefConfig.Definition.Key, (TextAnchor)3, new Color(0.9f, 0.9f, 0.7f), true, 14);
			Text obj = mainLabel;
			obj.text = obj.text + " <i>(" + SignatureHighlighter.Parse(RefConfig.SettingType, false, (MemberInfo)null) + ")</i>";
			UIFactory.SetLayoutElement(((Component)mainLabel).gameObject, (int?)200, (int?)22, (int?)9999, (int?)0, (int?)null, (int?)null, (bool?)null);
			ButtonRef val2 = UIFactory.CreateButton(val, "UndoButton", "Undo", (Color?)new Color(0.3f, 0.3f, 0.3f));
			val2.OnClick = (Action)Delegate.Combine(val2.OnClick, new Action(UndoEdits));
			undoButton = ((Component)val2.Component).gameObject;
			undoButton.SetActive(false);
			UIFactory.SetLayoutElement(undoButton, (int?)80, (int?)22, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null);
			ButtonRef val3 = UIFactory.CreateButton(val, "DefaultButton", "Default", (Color?)new Color(0.3f, 0.3f, 0.3f));
			val3.OnClick = (Action)Delegate.Combine(val3.OnClick, new Action(RevertToDefault));
			UIFactory.SetLayoutElement(((Component)val3.Component).gameObject, (int?)80, (int?)22, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null);
			if (RefConfig.Description != null && !string.IsNullOrEmpty(RefConfig.Description.Description))
			{
				Text val4 = UIFactory.CreateLabel(ContentGroup, "Description", "<i>" + RefConfig.Description.Description + "</i>", (TextAnchor)3, Color.grey, true, 14);
				UIFactory.SetLayoutElement(((Component)val4).gameObject, (int?)250, (int?)18, (int?)9999, (int?)0, (int?)null, (int?)null, (bool?)null);
			}
			SubContentGroup = UIFactory.CreateVerticalGroup(ContentGroup, "CacheObjectBase.SubContent", true, false, true, true, 0, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null);
			GameObject subContentGroup = SubContentGroup;
			num = 30;
			num2 = 9999;
			UIFactory.SetLayoutElement(subContentGroup, (int?)125, num, (int?)9000, num2, (int?)null, (int?)null, (bool?)null);
			SubContentGroup.SetActive(false);
			if (IValue != null)
			{
				IValue.mainContentParent = ContentGroup;
				IValue.subContentParent = SubContentGroup;
			}
		}
	}
	internal class ConfigFileInfo
	{
		public ConfigFile RefConfigFile;

		public BepInPlugin Meta;

		private List<EntryInfo> entries = new List<EntryInfo>();

		internal bool isCompletelyHidden;

		internal ButtonRef listButton;

		internal GameObject contentObj;

		internal IEnumerable<GameObject> HiddenEntries => from it in Entries
			where it.IsHidden
			select it.content;

		internal List<EntryInfo> Entries
		{
			get
			{
				return entries;
			}
			set
			{
				entries = value;
			}
		}
	}
	internal class EntryInfo
	{
		public ConfigEntryBase RefEntry;

		internal GameObject content;

		public CachedConfigEntry Cached { get; }

		public bool IsHidden { get; internal set; }

		public EntryInfo(CachedConfigEntry cached)
		{
			Cached = cached;
		}
	}
	public class UIManager : PanelBase
	{
		private static readonly Dictionary<string, ConfigFileInfo> ConfigFiles = new Dictionary<string, ConfigFileInfo>();

		private static readonly Dictionary<ConfigEntryBase, CachedConfigEntry> configsToCached = new Dictionary<ConfigEntryBase, CachedConfigEntry>();

		private static ConfigFileInfo currentCategory;

		private static readonly HashSet<CachedConfigEntry> editingEntries = new HashSet<CachedConfigEntry>();

		internal static ButtonRef saveButton;

		internal static UIBase uiBase;

		internal static GameObject CategoryListContent;

		internal static GameObject ConfigEditorContent;

		private static string currentFilter;

		private static Color normalInactiveColor = new Color(0.38f, 0.34f, 0.34f);

		private static Color normalActiveColor = UnityHelpers.ToColor("c2b895");

		public static UIManager Instance { get; internal set; }

		public override string Name => "<b>BepInExConfigManager</b> <i>1.3.0</i>";

		public override int MinWidth => 750;

		public override int MinHeight => 750;

		public override Vector2 DefaultAnchorMin => new Vector2(0.2f, 0.02f);

		public override Vector2 DefaultAnchorMax => new Vector2(0.8f, 0.98f);

		public static bool ShowMenu
		{
			get
			{
				return uiBase != null && uiBase.Enabled;
			}
			set
			{
				if (uiBase != null && Object.op_Implicit((Object)(object)uiBase.RootObject) && uiBase.Enabled != value)
				{
					UniversalUI.SetUIActive("com.sinai.BepInExConfigManager", value);
					((UIModel)Instance).SetActive(value);
				}
			}
		}

		public static bool ShowHiddenConfigs { get; internal set; }

		internal static string Filter => currentFilter ?? "";

		public UIManager(UIBase owner)
			: base(owner)
		{
			Instance = this;
		}

		internal static void Init()
		{
			uiBase = UniversalUI.RegisterUI("com.sinai.BepInExConfigManager", (Action)null);
			CreateMenu();
			Canvas.ForceUpdateCanvases();
			ShowMenu = false;
			SetupCategories();
		}

		internal static void SetupCategories()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			ConfigFile val = (ConfigFile)AccessTools.Property(typeof(ConfigFile), "CoreConfig").GetValue(null, null);
			if (val != null)
			{
				SetupCategory(val, null, new BepInPlugin("bepinex.core.config", "BepInEx", "1.0"), isCoreConfig: true, forceAdvanced: true);
			}
			foreach (CachedConfigFile configFile in Patcher.ConfigFiles)
			{
				ProcessConfigFile(configFile);
			}
			Patcher.ConfigFileCreated = (Action<CachedConfigFile>)Delegate.Combine(Patcher.ConfigFileCreated, new Action<CachedConfigFile>(ProcessConfigFile));
		}

		private static void ProcessConfigFile(CachedConfigFile cachedConfig)
		{
			RuntimeHelper.StartCoroutine(DelayedProcess(cachedConfig));
		}

		private static IEnumerator DelayedProcess(CachedConfigFile cachedConfig)
		{
			yield return null;
			SetupCategory(cachedConfig.configFile, null, cachedConfig.metadata, isCoreConfig: false);
			cachedConfig.configFile.SettingChanged += ConfigFile_SettingChanged;
		}

		private static void ConfigFile_SettingChanged(object sender, SettingChangedEventArgs e)
		{
			try
			{
				configsToCached[(ConfigEntryBase)((sender is ConfigEntryBase) ? sender : null)].OnSettingChanged(sender, (EventArgs)(object)e);
			}
			catch (Exception ex)
			{
				ConfigManager.LogSource.LogWarning((object)ex);
			}
		}

		internal static void SetupCategory(ConfigFile configFile, object plugin, BepInPlugin meta, bool isCoreConfig, bool forceAdvanced = false)
		{
			//IL_016d: 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_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: 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_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string GUID = ((meta != null) ? meta.GUID : null) ?? Path.GetFileNameWithoutExtension(configFile.ConfigFilePath);
				string text = ((meta != null) ? meta.Name : null) ?? GUID;
				BaseUnityPlugin val = (BaseUnityPlugin)((plugin is BaseUnityPlugin) ? plugin : null);
				if (!forceAdvanced && (Object)(object)val != (Object)null)
				{
					Type type = ((object)val).GetType();
					if (type.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>().Any((BrowsableAttribute it) => !it.Browsable))
					{
						forceAdvanced = true;
					}
				}
				ConfigFileInfo configFileInfo = new ConfigFileInfo
				{
					RefConfigFile = configFile,
					Meta = meta
				};
				ButtonRef val2 = UIFactory.CreateButton(CategoryListContent, "BUTTON_" + GUID, text, (Color?)null);
				val2.OnClick = (Action)Delegate.Combine(val2.OnClick, (Action)delegate
				{
					SetActiveCategory(GUID);
				});
				GameObject gameObject = ((Component)val2.Component).gameObject;
				int? num = 9999;
				int? num2 = 30;
				int? num3 = 0;
				UIFactory.SetLayoutElement(gameObject, (int?)null, num2, num, num3, (int?)null, (int?)null, (bool?)null);
				RuntimeHelper.SetColorBlock((Selectable)(object)val2.Component, (Color?)normalInactiveColor, (Color?)new Color(0.6f, 0.55f, 0.45f), (Color?)new Color(0.2f, 0.18f, 0.15f), (Color?)null);
				configFileInfo.listButton = val2;
				GameObject val3 = UIFactory.CreateVerticalGroup(ConfigEditorContent, "CATEGORY_" + GUID, true, false, true, true, 4, default(Vector4), new Color(0.05f, 0.05f, 0.05f), (TextAnchor?)null);
				Dictionary<string, List<ConfigEntryBase>> dictionary = new Dictionary<string, List<ConfigEntryBase>> { 
				{
					"",
					new List<ConfigEntryBase>()
				} };
				foreach (ConfigDefinition key in configFile.Keys)
				{
					string text2 = key.Section;
					if (text2 == null)
					{
						text2 = "";
					}
					if (!dictionary.ContainsKey(text2))
					{
						dictionary.Add(text2, new List<ConfigEntryBase>());
					}
					dictionary[text2].Add(configFile[key]);
				}
				foreach (KeyValuePair<string, List<ConfigEntryBase>> item in dictionary)
				{
					if (!string.IsNullOrEmpty(item.Key))
					{
						GameObject val4 = UIFactory.CreateHorizontalGroup(val3, "TitleBG", true, true, true, true, 0, default(Vector4), new Color(0.07f, 0.07f, 0.07f), (TextAnchor?)null);
						Text val5 = UIFactory.CreateLabel(val4, "Title_" + item.Key, item.Key, (TextAnchor)4, default(Color), true, 17);
						GameObject gameObject2 = ((Component)val5).gameObject;
						num3 = 30;
						UIFactory.SetLayoutElement(gameObject2, (int?)200, num3, (int?)9999, (int?)null, (int?)null, (int?)null, (bool?)null);
					}
					foreach (ConfigEntryBase item2 in item.Value)
					{
						CachedConfigEntry cachedConfigEntry = new CachedConfigEntry(item2, val3);
						cachedConfigEntry.Enable();
						configsToCached.Add(item2, cachedConfigEntry);
						GameObject uIroot = cachedConfigEntry.UIroot;
						bool flag = forceAdvanced;
						if (!flag)
						{
							ConfigDescription description = item2.Description;
							object[] array = ((description != null) ? description.Tags : null);
							if (array != null && array.Any())
							{
								if (array.Any((object it) => it is string text3 && text3 == "Advanced"))
								{
									flag = true;
								}
								else
								{
									object obj = array.FirstOrDefault((object it) => it.GetType().Name == "ConfigurationManagerAttributes");
									if (obj != null)
									{
										flag = (bool?)obj.GetType().GetField("IsAdvanced")?.GetValue(obj) == true;
									}
								}
							}
						}
						configFileInfo.Entries.Add(new EntryInfo(cachedConfigEntry)
						{
							RefEntry = item2,
							content = uIroot,
							IsHidden = flag
						});
					}
				}
				if (!configFileInfo.Entries.Any((EntryInfo it) => !it.IsHidden))
				{
					((Component)val2.Component).gameObject.SetActive(false);
					configFileInfo.isCompletelyHidden = true;
				}
				val3.SetActive(false);
				configFileInfo.contentObj = val3;
				ConfigFiles.Add(GUID, configFileInfo);
			}
			catch (Exception arg)
			{
				if (meta != null)
				{
					ConfigManager.LogSource.LogWarning((object)$"Exception setting up category '{meta.GUID}'!\r\n{arg}");
					return;
				}
				string arg2;
				try
				{
					arg2 = Path.GetFileNameWithoutExtension(configFile.ConfigFilePath);
				}
				catch
				{
					arg2 = "UNKNOWN";
				}
				ConfigManager.LogSource.LogWarning((object)$"Exception setting up category (no meta): {arg2}\n{arg}");
			}
		}

		internal static void CreateMenu()
		{
			if (Instance != null)
			{
				ConfigManager.LogSource.LogWarning((object)"An instance of ConfigurationEditor already exists, cannot create another!");
			}
			else
			{
				new UIManager(uiBase);
			}
		}

		public static void OnEntryEdit(CachedConfigEntry entry)
		{
			if (!editingEntries.Contains(entry))
			{
				editingEntries.Add(entry);
			}
			if (!((Selectable)saveButton.Component).interactable)
			{
				((Selectable)saveButton.Component).interactable = true;
			}
		}

		public static void OnEntrySaveOrUndo(CachedConfigEntry entry)
		{
			if (editingEntries.Contains(entry))
			{
				editingEntries.Remove(entry);
			}
			if (!editingEntries.Any())
			{
				((Selectable)saveButton.Component).interactable = false;
			}
		}

		public static void SavePreferences()
		{
			foreach (ConfigFileInfo value in ConfigFiles.Values)
			{
				foreach (EntryInfo entry in value.Entries)
				{
					entry.RefEntry.BoxedValue = entry.Cached.EditedValue;
				}
				ConfigFile refConfigFile = value.RefConfigFile;
				if (!refConfigFile.SaveOnConfigSet)
				{
					refConfigFile.Save();
				}
			}
			for (int num = editingEntries.Count - 1; num >= 0; num--)
			{
				editingEntries.ElementAt(num).OnSaveOrUndo();
			}
			editingEntries.Clear();
			((Selectable)saveButton.Component).interactable = false;
		}

		public static void SetHiddenConfigVisibility(bool show)
		{
			if (ShowHiddenConfigs == show)
			{
				return;
			}
			ShowHiddenConfigs = show;
			foreach (KeyValuePair<string, ConfigFileInfo> configFile in ConfigFiles)
			{
				ConfigFileInfo value = configFile.Value;
				if (value.isCompletelyHidden)
				{
					((Component)value.listButton.Component).gameObject.SetActive(ShowHiddenConfigs);
				}
			}
			if (currentCategory != null && !ShowHiddenConfigs && currentCategory.isCompletelyHidden)
			{
				UnsetActiveCategory();
			}
			RefreshFilter();
		}

		public static void FilterConfigs(string search)
		{
			currentFilter = search.ToLower();
			RefreshFilter();
		}

		internal static void RefreshFilter()
		{
			if (currentCategory == null)
			{
				return;
			}
			using List<EntryInfo>.Enumerator enumerator = currentCategory.Entries.GetEnumerator();
			EntryInfo current;
			int num;
			bool active;
			for (; enumerator.MoveNext(); active = (byte)num != 0, current.content.SetActive(active))
			{
				current = enumerator.Current;
				if (!string.IsNullOrEmpty(currentFilter) && !current.RefEntry.Definition.Key.ToLower().Contains(currentFilter))
				{
					ConfigDescription description = current.RefEntry.Description;
					if (!((description == null) ? null : description.Description?.Contains(currentFilter)).GetValueOrDefault())
					{
						num = 0;
						continue;
					}
				}
				num = ((!current.IsHidden || ShowHiddenConfigs) ? 1 : 0);
			}
		}

		public static void SetActiveCategory(string categoryIdentifier)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (ConfigFiles.ContainsKey(categoryIdentifier))
			{
				UnsetActiveCategory();
				ConfigFileInfo configFileInfo = (currentCategory = ConfigFiles[categoryIdentifier]);
				GameObject contentObj = configFileInfo.contentObj;
				contentObj.SetActive(true);
				ButtonRef listButton = configFileInfo.listButton;
				RuntimeHelper.SetColorBlock((Selectable)(object)listButton.Component, (Color?)normalActiveColor, (Color?)null, (Color?)null, (Color?)null);
				RefreshFilter();
			}
		}

		internal static void UnsetActiveCategory()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (currentCategory != null)
			{
				RuntimeHelper.SetColorBlock((Selectable)(object)currentCategory.listButton.Component, (Color?)normalInactiveColor, (Color?)null, (Color?)null, (Color?)null);
				currentCategory.contentObj.SetActive(false);
				currentCategory = null;
			}
		}

		protected override void ConstructPanelContent()
		{
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(((PanelBase)this).ContentRoot, (bool?)true, (bool?)false, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null);
			ConstructTitleBar();
			ConstructSaveButton();
			ConstructToolbar();
			ConstructEditorViewport();
		}

		protected override void OnClosePanelClicked()
		{
			((PanelBase)this).OnClosePanelClicked();
			ShowMenu = false;
		}

		private void ConstructTitleBar()
		{
			//IL_0040: 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_0072: 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)
			Text component = ((Component)((PanelBase)this).TitleBar.transform.GetChild(0)).GetComponent<Text>();
			component.text = "<b><color=#8b736b>BepInExConfigManager</color></b> <i><color=#ffe690>v1.3.0</color></i>";
			Button componentInChildren = ((PanelBase)this).TitleBar.GetComponentInChildren<Button>();
			RuntimeHelper.SetColorBlock((Selectable)(object)componentInChildren, (Color?)new Color(1f, 0.2f, 0.2f), (Color?)new Color(1f, 0.6f, 0.6f), (Color?)new Color(0.3f, 0.1f, 0.1f), (Color?)null);
			Text componentInChildren2 = ((Component)componentInChildren).GetComponentInChildren<Text>();
			((Graphic)componentInChildren2).color = Color.white;
			componentInChildren2.resizeTextForBestFit = true;
			componentInChildren2.resizeTextMinSize = 8;
			componentInChildren2.resizeTextMaxSize = 14;
		}

		private void ConstructSaveButton()
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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)
			saveButton = UIFactory.CreateButton(((PanelBase)this).ContentRoot, "SaveButton", "Save Preferences", (Color?)null);
			ButtonRef obj = saveButton;
			obj.OnClick = (Action)Delegate.Combine(obj.OnClick, new Action(SavePreferences));
			GameObject gameObject = ((Component)saveButton.Component).gameObject;
			int? num = 35;
			int? num2 = 0;
			int? num3 = 9999;
			UIFactory.SetLayoutElement(gameObject, (int?)null, num, num3, num2, (int?)null, (int?)null, (bool?)null);
			RuntimeHelper.SetColorBlock((Selectable)(object)saveButton.Component, (Color?)new Color(0.1f, 0.3f, 0.1f), (Color?)new Color(0.2f, 0.5f, 0.2f), (Color?)new Color(0.1f, 0.2f, 0.1f), (Color?)new Color(0.2f, 0.2f, 0.2f));
			((Selectable)saveButton.Component).interactable = false;
			((Component)saveButton.Component).gameObject.SetActive(!ConfigManager.Auto_Save_Configs.Value);
		}

		private void ConstructToolbar()
		{
			//IL_0025: 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_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)
			GameObject val2 = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot, "Toolbar", false, false, true, true, 4, new Vector4(3f, 3f, 3f, 3f), new Color(0.1f, 0.1f, 0.1f), (TextAnchor?)null);
			Toggle val3 = default(Toggle);
			Text val4 = default(Text);
			GameObject val5 = UIFactory.CreateToggle(val2, "HiddenConfigsToggle", ref val3, ref val4, default(Color), 20, 20);
			val3.isOn = false;
			((UnityEvent<bool>)(object)val3.onValueChanged).AddListener((UnityAction<bool>)delegate(bool val)
			{
				SetHiddenConfigVisibility(val);
			});
			val4.text = "Show Advanced Settings";
			int? num = 280;
			int? num2 = 25;
			int? num3 = 0;
			UIFactory.SetLayoutElement(val5, num, num2, (int?)0, num3, (int?)null, (int?)null, (bool?)null);
			InputFieldRef val6 = UIFactory.CreateInputField(val2, "FilterInput", "Search...");
			GameObject gameObject = ((Component)val6.Component).gameObject;
			num3 = 9999;
			int? num4 = 25;
			UIFactory.SetLayoutElement(gameObject, (int?)null, num4, num3, (int?)null, (int?)null, (int?)null, (bool?)null);
			val6.OnValueChanged += FilterConfigs;
		}

		private void ConstructEditorViewport()
		{
			//IL_0013: 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_002a: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = UIFactory.CreateHorizontalGroup(((PanelBase)this).ContentRoot, "Main", true, true, true, true, 2, default(Vector4), new Color(0.08f, 0.08f, 0.08f), (TextAnchor?)null);
			GameObject val2 = default(GameObject);
			AutoSliderScrollbar val3 = default(AutoSliderScrollbar);
			GameObject val4 = UIFactory.CreateScrollView(val, "CategoryList", ref val2, ref val3, new Color(0.1f, 0.1f, 0.1f));
			int? num = 300;
			int? num2 = 0;
			UIFactory.SetLayoutElement(val4, num, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null);
			CategoryListContent = val2;
			GameObject obj = val2;
			num2 = 3;
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(obj, (bool?)null, (bool?)null, (bool?)null, (bool?)null, num2, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null);
			GameObject configEditorContent = default(GameObject);
			GameObject val5 = UIFactory.CreateScrollView(val, "ConfigEditor", ref configEditorContent, ref val3, new Color(0.05f, 0.05f, 0.05f));
			num2 = 9999;
			UIFactory.SetLayoutElement(val5, (int?)null, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null);
			ConfigEditorContent = configEditorContent;
		}
	}
}
namespace ConfigManager.UI.InteractiveValues
{
	public class InteractiveBool : InteractiveValue
	{
		internal Toggle toggle;

		private Text labelText;

		public InteractiveBool(object value, Type valueType)
			: base(value, valueType)
		{
		}

		public override bool SupportsType(Type type)
		{
			return (object)type == typeof(bool);
		}

		public override void RefreshUIForValue()
		{
			bool flag = (bool)Value;
			if (!((Component)toggle).gameObject.activeSelf)
			{
				((Component)toggle).gameObject.SetActive(true);
			}
			if (flag != toggle.isOn)
			{
				toggle.isOn = flag;
			}
			string arg = (flag ? "6bc981" : "c96b6b");
			labelText.text = $"<color=#{arg}>{flag}</color>";
		}

		internal void OnToggleValueChanged(bool val)
		{
			Value = val;
			RefreshUIForValue();
			Owner.SetValueFromIValue();
		}

		public override void ConstructUI(GameObject parent)
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			base.ConstructUI(parent);
			bool flag = false;
			Text val2 = default(Text);
			while (!flag)
			{
				GameObject val = null;
				try
				{
					val = UIFactory.CreateToggle(mainContent, "InteractiveBoolToggle", ref toggle, ref val2, new Color(0.1f, 0.1f, 0.1f), 20, 20);
					UIFactory.SetLayoutElement(val, (int?)24, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
					((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)OnToggleValueChanged);
					flag = true;
				}
				catch
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						Object.Destroy((Object)(object)val);
					}
				}
			}
			labelText = UIFactory.CreateLabel(mainContent, "TrueFalseLabel", "False", (TextAnchor)3, default(Color), true, 14);
			UIFactory.SetLayoutElement(((Component)labelText).gameObject, (int?)60, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
			RefreshUIForValue();
		}
	}
	public class InteractiveColor : InteractiveValue
	{
		private Image colorImage;

		private readonly InputField[] inputs = (InputField[])(object)new InputField[4];

		private readonly Slider[] sliders = (Slider[])(object)new Slider[4];

		private static readonly string[] fieldNames = new string[4] { "R", "G", "B", "A" };

		public InteractiveColor(object value, Type valueType)
			: base(value, valueType)
		{
		}

		public override bool SupportsType(Type type)
		{
			return (object)type == typeof(Color) || (object)type == typeof(Color32);
		}

		public override void RefreshUIForValue()
		{
			base.RefreshUIForValue();
			RefreshColorUI();
		}

		private void RefreshColorUI()
		{
			//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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			if (Value is Color32 val)
			{
				inputs[0].text = val.r.ToString();
				inputs[1].text = val.g.ToString();
				inputs[2].text = val.b.ToString();
				inputs[3].text = val.a.ToString();
				if (Object.op_Implicit((Object)(object)colorImage))
				{
					((Graphic)colorImage).color = Color32.op_Implicit(val);
				}
				return;
			}
			object value = Value;
			if (!(value is Color))
			{
				return;
			}
			Color color = (Color)value;
			if (true)
			{
				inputs[0].text = color.r.ToString();
				inputs[1].text = color.g.ToString();
				inputs[2].text = color.b.ToString();
				inputs[3].text = color.a.ToString();
				if (Object.op_Implicit((Object)(object)colorImage))
				{
					((Graphic)colorImage).color = color;
				}
			}
		}

		protected internal override void OnToggleSubcontent(bool toggle)
		{
			base.OnToggleSubcontent(toggle);
			RefreshColorUI();
		}

		public override void ConstructUI(GameObject parent)
		{
			//IL_001b: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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)
			base.ConstructUI(parent);
			GameObject val = UIFactory.CreateHorizontalGroup(mainContent, "ColorEditor", false, false, true, true, 5, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)(TextAnchor)3);
			GameObject val2 = UIFactory.CreateVerticalGroup(val, "ImgHolder", true, true, true, true, 0, new Vector4(1f, 1f, 1f, 1f), new Color(0.08f, 0.08f, 0.08f), (TextAnchor?)null);
			UIFactory.SetLayoutElement(val2, (int?)50, (int?)25, (int?)999, (int?)0, (int?)null, (int?)null, (bool?)null);
			GameObject val3 = UIFactory.CreateUIObject("ColorImageHelper", val2, new Vector2(100f, 25f));
			colorImage = val3.AddComponent<Image>();
			((Graphic)colorImage).color = (Color)((Value is Color) ? ((Color)Value) : Color32.op_Implicit((Color32)Value));
			GameObject val4 = UIFactory.CreateVerticalGroup(val, "EditorsGroup", false, false, true, true, 3, new Vector4(3f, 3f, 3f, 3f), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null);
			GameObject val5 = UIFactory.CreateGridGroup(val4, "Grid", new Vector2(140f, 25f), new Vector2(2f, 2f), new Color(1f, 1f, 1f, 0f));
			UIFactory.SetLayoutElement(val5, (int?)580, (int?)25, (int?)900, (int?)null, (int?)null, (int?)null, (bool?)null);
			for (int i = 0; i < 4; i++)
			{
				AddEditorRow(i, val5);
			}
			RefreshUIForValue();
		}

		internal void AddEditorRow(int index, GameObject groupObj)
		{
			//IL_0033: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = UIFactory.CreateHorizontalGroup(groupObj, "EditorRow_" + fieldNames[index], false, true, true, true, 5, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null);
			Text val2 = UIFactory.CreateLabel(val, "RowLabel", fieldNames[index] + ":", (TextAnchor)5, Color.cyan, true, 14);
			GameObject gameObject = ((Component)val2).gameObject;
			int? num = 17;
			int? num2 = 0;
			UIFactory.SetLayoutElement(gameObject, num, (int?)25, num2, (int?)null, (int?)null, (int?)null, (bool?)null);
			InputFieldRef inputField = UIFactory.CreateInputField(val, "InputField", "...");
			UIFactory.SetLayoutElement(((Component)inputField.Component).gameObject, (int?)40, (int?)25, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null);
			inputs[index] = inputField.Component;
			inputField.Component.characterValidation = (CharacterValidation)((!(Value is Color)) ? 1 : 2);
			inputField.OnValueChanged += delegate(string value)
			{
				if (Value is Color)
				{
					float num3 = float.Parse(value);
					SetValueToColor(num3);
					sliders[index].value = num3;
				}
				else
				{
					byte b = byte.Parse(value);
					SetValueToColor32(b);
					sliders[index].value = (int)b;
				}
			};
			Slider val3 = default(Slider);
			GameObject val4 = UIFactory.CreateSlider(val, "Slider", ref val3);
			sliders[index] = val3;
			num2 = 25;
			UIFactory.SetLayoutElement(val4, (int?)70, num2, (int?)999, (int?)0, (int?)null, (int?)null, (bool?)null);
			val3.minValue = 0f;
			if (Value is Color)
			{
				val3.maxValue = 1f;
				val3.value = GetValueFromColor();
			}
			else
			{
				val3.maxValue = 255f;
				val3.value = (int)GetValueFromColor32();
			}
			((UnityEvent<float>)(object)val3.onValueChanged).AddListener((UnityAction<float>)delegate(float value)
			{
				try
				{
					if (Value is Color32)
					{
						string text = ((byte)value).ToString();
						inputField.Text = text;
						SetValueToColor32((byte)value);
						inputs[index].text = text;
					}
					else
					{
						inputField.Text = value.ToString();
						SetValueToColor(value);
						inputs[index].text = value.ToString();
					}
				}
				catch (Exception ex)
				{
					ConfigManager.LogSource.LogMessage((object)ex.ToString());
				}
			});
			float GetValueFromColor()
			{
				//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)
				//IL_0035: 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_0047: 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)
				Color val6 = (Color)Value;
				if (1 == 0)
				{
				}
				float result2 = index switch
				{
					0 => val6.r, 
					1 => val6.g, 
					2 => val6.b, 
					3 => val6.a, 
					_ => throw new NotImplementedException(), 
				};
				if (1 == 0)
				{
				}
				return result2;
			}
			byte GetValueFromColor32()
			{
				//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)
				//IL_0035: 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_0047: 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)
				Color32 val5 = (Color32)Value;
				if (1 == 0)
				{
				}
				byte result = index switch
				{
					0 => val5.r, 
					1 => val5.g, 
					2 => val5.b, 
					3 => val5.a, 
					_ => throw new NotImplementedException(), 
				};
				if (1 == 0)
				{
				}
				return result;
			}
			void SetValueToColor(float floatValue)
			{
				//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)
				//IL_0061: 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)
				Color val8 = (Color)Value;
				switch (index)
				{
				case 0:
					val8.r = floatValue;
					break;
				case 1:
					val8.g = floatValue;
					break;
				case 2:
					val8.b = floatValue;
					break;
				case 3:
					val8.a = floatValue;
					break;
				}
				Value = val8;
				((Graphic)colorImage).color = val8;
				Owner.SetValueFromIValue();
			}
			void SetValueToColor32(byte byteValue)
			{
				//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)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				Color32 val7 = (Color32)Value;
				switch (index)
				{
				case 0:
					val7.r = byteValue;
					break;
				case 1:
					val7.g = byteValue;
					break;
				case 2:
					val7.b = byteValue;
					break;
				case 3:
					val7.a = byteValue;
					break;
				}
				Value = val7;
				((Graphic)colorImage).color = Color32.op_Implicit(val7);
				Owner.SetValueFromIValue();
			}
		}
	}
	public class InteractiveEnum : InteractiveValue
	{
		internal static Dictionary<Type, KeyValuePair<long, string>[]> enumNamesCache = new Dictionary<Type, KeyValuePair<long, string>[]>();

		internal KeyValuePair<long, string>[] values = new KeyValuePair<long, string>[0];

		internal Dictionary<string, OptionData> dropdownOptions = new Dictionary<string, OptionData>();

		internal Dropdown dropdown;

		public InteractiveEnum(object value, Type valueType)
			: base(value, valueType)
		{
			if (value != null)
			{
				GetNames();
			}
		}

		public override bool SupportsType(Type type)
		{
			return type.IsEnum;
		}

		internal void GetNames()
		{
			Type type = Value?.GetType() ?? FallbackType;
			if (!enumNamesCache.ContainsKey(type))
			{
				Array array = Enum.GetValues(type);
				List<KeyValuePair<long, string>> list = new List<KeyValuePair<long, string>>();
				HashSet<string> hashSet = new HashSet<string>();
				foreach (object item in array)
				{
					string text = item.ToString();
					if (!hashSet.Contains(text))
					{
						hashSet.Add(text);
						Type underlyingType = Enum.GetUnderlyingType(type);
						long key;
						try
						{
							object value = Convert.ChangeType(item, underlyingType);
							key = (long)Convert.ChangeType(value, typeof(long));
						}
						catch (Exception ex)
						{
							ConfigManager.LogSource.LogWarning((object)("[InteractiveEnum] Could not Unbox underlying type " + underlyingType.Name + " from " + type.FullName));
							ConfigManager.LogSource.LogMessage((object)ex.ToString());
							continue;
						}
						list.Add(new KeyValuePair<long, string>(key, text));
					}
				}
				enumNamesCache.Add(type, list.ToArray());
			}
			values = enumNamesCache[type];
		}

		public override void OnValueUpdated()
		{
			GetNames();
			base.OnValueUpdated();
		}

		public override void RefreshUIForValue()
		{
			base.RefreshUIForValue();
			if (!(this is InteractiveFlags))
			{
				string key = Value.ToString();
				if (dropdownOptions.ContainsKey(key))
				{
					dropdown.value = dropdown.options.IndexOf(dropdownOptions[key]);
				}
			}
		}

		private void SetValueFromDropdown()
		{
			Type type = Value?.GetType() ?? FallbackType;
			int value = dropdown.value;
			object obj = Enum.Parse(type, enumNamesCache[type][value].Value);
			if (obj != null)
			{
				Value = obj;
				Owner.SetValueFromIValue();
				RefreshUIForValue();
			}
		}

		public override void ConstructUI(GameObject parent)
		{
			//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_00cc: Expected O, but got Unknown
			base.ConstructUI(parent);
			if (!(this is InteractiveFlags))
			{
				GameObject val2 = UIFactory.CreateDropdown(mainContent, "InteractiveDropdown", ref dropdown, "", 14, (Action<int>)null, (string[])null);
				UIFactory.SetLayoutElement(val2, (int?)400, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
				((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate
				{
					SetValueFromDropdown();
				});
				KeyValuePair<long, string>[] array = values;
				for (int i = 0; i < array.Length; i++)
				{
					KeyValuePair<long, string> keyValuePair = array[i];
					OptionData val3 = new OptionData
					{
						text = keyValuePair.Value
					};
					dropdown.options.Add(val3);
					dropdownOptions.Add(keyValuePair.Value, val3);
				}
			}
		}
	}
	public class InteractiveFlags : InteractiveEnum
	{
		internal bool[] enabledFlags;

		internal Toggle[] toggles;

		private bool refreshingToggleStates;

		public override bool HasSubContent => true;

		public override bool SubContentWanted => true;

		public InteractiveFlags(object value, Type valueType)
			: base(value, valueType)
		{
			toggles = (Toggle[])(object)new Toggle[values.Length];
			enabledFlags = new bool[values.Length];
		}

		public override bool SupportsType(Type type)
		{
			return type.IsEnum && type.GetCustomAttributes(inherit: true).Any((object it) => it is FlagsAttribute);
		}

		public override void OnValueUpdated()
		{
			List<string> list = new List<string>();
			IEnumerable<string> enumerable = (from it in Value?.ToString().Split(new char[1] { ',' })
				select it.Trim());
			if (enumerable != null)
			{
				list.AddRange(enumerable);
			}
			for (int i = 0; i < values.Length; i++)
			{
				enabledFlags[i] = list.Contains(values[i].Value);
			}
			base.OnValueUpdated();
		}

		public override void RefreshUIForValue()
		{
			base.RefreshUIForValue();
			if (!subContentConstructed)
			{
				return;
			}
			refreshingToggleStates = true;
			for (int i = 0; i < values.Length; i++)
			{
				Toggle val = toggles[i];
				if (val.isOn != enabledFlags[i])
				{
					val.isOn = enabledFlags[i];
				}
			}
			refreshingToggleStates = false;
		}

		private void SetValueFromToggles()
		{
			string text = "";
			for (int i = 0; i < values.Length; i++)
			{
				if (enabledFlags[i])
				{
					if (text != "")
					{
						text += ", ";
					}
					text += values[i].Value;
				}
			}
			if (!string.IsNullOrEmpty(text))
			{
				Type enumType = Value?.GetType() ?? FallbackType;
				Value = Enum.Parse(enumType, text);
				RefreshUIForValue();
				Owner.SetValueFromIValue();
			}
		}

		protected internal override void OnToggleSubcontent(bool toggle)
		{
			base.OnToggleSubcontent(toggle);
			RefreshUIForValue();
		}

		public override void ConstructUI(GameObject parent)
		{
			base.ConstructUI(parent);
		}

		public override void ConstructSubcontent()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			subContentConstructed = true;
			GameObject groupObj = UIFactory.CreateVerticalGroup(subContentParent, "InteractiveFlagsContent", false, true, true, true, 5, new Vector4(3f, 3f, 3f, 3f), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null);
			for (int i = 0; i < values.Length; i++)
			{
				AddToggle(i, groupObj);
			}
		}

		internal void AddToggle(int index, GameObject groupObj)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			KeyValuePair<long, string> keyValuePair = values[index];
			Toggle val2 = default(Toggle);
			Text val3 = default(Text);
			GameObject val4 = UIFactory.CreateToggle(groupObj, "FlagToggle", ref val2, ref val3, new Color(0.1f, 0.1f, 0.1f), 20, 20);
			int? num = 100;
			int? num2 = 2000;
			UIFactory.SetLayoutElement(val4, num, (int?)25, num2, (int?)null, (int?)null, (int?)null, (bool?)null);
			toggles[index] = val2;
			((UnityEvent<bool>)(object)val2.onValueChanged).AddListener((UnityAction<bool>)delegate(bool val)
			{
				if (!refreshingToggleStates)
				{
					enabledFlags[index] = val;
					SetValueFromToggles();
					RefreshUIForValue();
				}
			});
			val3.text = keyValuePair.Value;
		}
	}
	public class InteractiveFloatStruct : InteractiveValue
	{
		public class StructInfo
		{
			private readonly FieldInfo[] fields;

			public string[] FieldNames { get; }

			public StructInfo(Type type)
			{
				fields = (from it in type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
					where !it.IsLiteral
					select it).ToArray();
				FieldNames = fields.Select((FieldInfo it) => it.Name).ToArray();
			}

			public object SetValue(ref object instance, int fieldIndex, float val)
			{
				fields[fieldIndex].SetValue(instance, val);
				return instance;
			}

			public float GetValue(object instance, int fieldIndex)
			{
				return (float)fields[fieldIndex].GetValue(instance);
			}

			public void RefreshUI(InputField[] inputs, object instance)
			{
				try
				{
					for (int i = 0; i < fields.Length; i++)
					{
						FieldInfo fieldInfo = fields[i];
						float num = (float)fieldInfo.GetValue(instance);
						inputs[i].text = num.ToString();
					}
				}
				catch (Exception ex)
				{
					ConfigManager.LogSource.LogMessage((object)ex);
				}
			}
		}

		private static readonly Dictionary<string, bool> _typeSupportCache = new Dictionary<string, bool>();

		public StructInfo structInfo;

		internal Type lastStructType;

		internal InputField[] inputs;

		public static bool IsTypeSupported(Type type)
		{
			if (!type.IsValueType)
			{
				return false;
			}
			if (_typeSupportCache.TryGetValue(type.AssemblyQualifiedName, out var value))
			{
				return value;
			}
			value = true;
			FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				if (!fieldInfo.IsLiteral && !typeof(float).IsAssignableFrom(fieldInfo.FieldType))
				{
					value = false;
					break;
				}
			}
			_typeSupportCache.Add(type.AssemblyQualifiedName, value);
			return value;
		}

		public InteractiveFloatStruct(object value, Type valueType)
			: base(value, valueType)
		{
		}

		public override bool SupportsType(Type type)
		{
			return IsTypeSupported(type);
		}

		public override void RefreshUIForValue()
		{
			InitializeStructInfo();
			base.RefreshUIForValue();
			structInfo.RefreshUI(inputs, Value);
		}

		internal void InitializeStructInfo()
		{
			Type type = Value?.GetType() ?? FallbackType;
			if (structInfo == null || (object)type != lastStructType)
			{
				lastStructType = type;
				structInfo = new StructInfo(type);
			}
		}

		public override void ConstructUI(GameObject parent)
		{
			//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_004e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				InitializeStructInfo();
				base.ConstructUI(parent);
				GameObject val = UIFactory.CreateGridGroup(mainContent, "EditorContent", new Vector2(150f, 25f), new Vector2(5f, 5f), new Color(1f, 1f, 1f, 0f));
				int? num = 300;
				int? num2 = 9999;
				UIFactory.SetLayoutElement(val, num, (int?)null, num2, (int?)null, (int?)null, (int?)null, (bool?)null);
				inputs = (InputField[])(object)new InputField[structInfo.FieldNames.Length];
				for (int i = 0; i < structInfo.FieldNames.Length; i++)
				{
					AddEditorRow(i, val);
				}
				RefreshUIForValue();
			}
			catch (Exception ex)
			{
				ConfigManager.LogSource.LogMessage((object)ex);
			}
		}

		internal void AddEditorRow(int index, GameObject groupObj)
		{
			//IL_0023: 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_003f: 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)
			try
			{
				GameObject val2 = UIFactory.CreateHorizontalGroup(groupObj, "EditorRow", false, true, true, true, 5, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)null);
				string text = structInfo.FieldNames[index];
				if (text.StartsWith("m_"))
				{
					text = text.Substring(2, text.Length - 2);
				}
				if (text.Length > 1)
				{
					text = text.Substring(0, 1);
				}
				Text val3 = UIFactory.CreateLabel(val2, "RowLabel", text + ":", (TextAnchor)5, Color.cyan, true, 14);
				GameObject gameObject = ((Component)val3).gameObject;
				int? num = 30;
				int? num2 = 0;
				UIFactory.SetLayoutElement(gameObject, num, (int?)25, num2, (int?)null, (int?)null, (int?)null, (bool?)null);
				InputFieldRef val4 = UIFactory.CreateInputField(val2, "InputField", "...");
				UIFactory.SetLayoutElement(((Component)val4.Component).gameObject, (int?)120, (int?)25, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null);
				inputs[index] = val4.Component;
				val4.OnValueChanged += delegate(string val)
				{
					try
					{
						float val5 = float.Parse(val);
						Value = structInfo.SetValue(ref Value, index, val5);
						Owner.SetValueFromIValue();
					}
					catch
					{
					}
				};
			}
			catch (Exception ex)
			{
				ConfigManager.LogSource.LogMessage((object)ex);
			}
		}
	}
	public class InteractiveKeycode : InteractiveValue
	{
		internal Text labelText;

		internal ButtonRef rebindButton;

		internal ButtonRef confirmButton;

		internal ButtonRef cancelButton;

		private readonly bool isInputSystem;

		public InteractiveKeycode(object value, Type valueType)
			: base(value, valueType)
		{
			isInputSystem = !(value is KeyCode);
		}

		public override bool SupportsType(Type type)
		{
			return (object)type == typeof(KeyCode) || type.FullName == "UnityEngine.InputSystem.Key";
		}

		public override void RefreshUIForValue()
		{
			base.RefreshUIForValue();
			labelText.text = Value.ToString();
		}

		public override void OnValueUpdated()
		{
			base.OnValueUpdated();
		}

		public void BeginRebind()
		{
			((Component)rebindButton.Component).gameObject.SetActive(false);
			((Component)confirmButton.Component).gameObject.SetActive(true);
			((Selectable)confirmButton.Component).interactable = false;
			((Component)cancelButton.Component).gameObject.SetActive(true);
			labelText.text = "<i>Press a key...</i>";
			InputManager.BeginRebind((Action<KeyCode>)OnRebindKeyPressed, (Action<KeyCode?>)OnKeycodeConfirmed);
		}

		private void OnRebindKeyPressed(KeyCode kc)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (!isInputSystem)
			{
				labelText.text = "<i>" + ((object)(KeyCode)(ref kc)).ToString() + "</i>";
			}
			else
			{
				object obj = InputSystem.KeyCodeToKeyEnum(kc);
				labelText.text = "<i>" + obj.ToString() + "</i>";
			}
			((Selectable)confirmButton.Component).interactable = true;
		}

		private void OnKeycodeConfirmed(KeyCode? kc)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (kc.HasValue)
			{
				if (!isInputSystem)
				{
					Value = kc;
				}
				else
				{
					Value = InputSystem.KeyCodeToKeyEnum(kc.Value);
				}
			}
			Owner.SetValueFromIValue();
			RefreshUIForValue();
		}

		public void ConfirmEndRebind()
		{
			InputManager.EndRebind();
			OnRebindEnd();
		}

		public void CancelEndRebind()
		{
			InputManager.LastRebindKey = null;
			InputManager.EndRebind();
			OnRebindEnd();
		}

		internal void OnRebindEnd()
		{
			((Component)rebindButton.Component).gameObject.SetActive(true);
			((Component)confirmButton.Component).gameObject.SetActive(false);
			((Component)cancelButton.Component).gameObject.SetActive(false);
		}

		public override void ConstructUI(GameObject parent)
		{
			//IL_0033: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			base.ConstructUI(parent);
			labelText = UIFactory.CreateLabel(mainContent, "Label", Value?.ToString() ?? "<notset>", (TextAnchor)3, default(Color), true, 14);
			UIFactory.SetLayoutElement(((Component)labelText).gameObject, (int?)150, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
			rebindButton = UIFactory.CreateButton(mainContent, "RebindButton", "Rebind", (Color?)null);
			ButtonRef obj = rebindButton;
			obj.OnClick = (Action)Delegate.Combine(obj.OnClick, new Action(BeginRebind));
			GameObject gameObject = ((Component)rebindButton.Component).gameObject;
			int? num = 25;
			UIFactory.SetLayoutElement(gameObject, (int?)100, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
			confirmButton = UIFactory.CreateButton(mainContent, "ConfirmButton", "Confirm", (Color?)new Color(0.1f, 0.4f, 0.1f));
			ButtonRef obj2 = confirmButton;
			obj2.OnClick = (Action)Delegate.Combine(obj2.OnClick, new Action(ConfirmEndRebind));
			GameObject gameObject2 = ((Component)confirmButton.Component).gameObject;
			num = 25;
			UIFactory.SetLayoutElement(gameObject2, (int?)100, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
			((Component)confirmButton.Component).gameObject.SetActive(false);
			Button component = confirmButton.Component;
			Color? val = new Color(0.3f, 0.3f, 0.3f);
			RuntimeHelper.SetColorBlock((Selectable)(object)component, (Color?)null, (Color?)null, (Color?)null, val);
			cancelButton = UIFactory.CreateButton(mainContent, "EndButton", "Cancel", (Color?)new Color(0.4f, 0.1f, 0.1f));
			ButtonRef obj3 = cancelButton;
			obj3.OnClick = (Action)Delegate.Combine(obj3.OnClick, new Action(CancelEndRebind));
			GameObject gameObject3 = ((Component)cancelButton.Component).gameObject;
			num = 25;
			UIFactory.SetLayoutElement(gameObject3, (int?)100, num, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
			((Component)cancelButton.Component).gameObject.SetActive(false);
		}
	}
	public class InteractiveNumber : InteractiveValue
	{
		internal InputFieldRef valueInput;

		private Slider slider;

		private MethodInfo parseMethod;

		public MethodInfo ParseMethod => parseMethod ?? (parseMethod = Value.GetType().GetMethod("Parse", new Type[1] { typeof(string) }));

		public InteractiveNumber(object value, Type valueType)
			: base(value, valueType)
		{
		}

		public override bool SupportsType(Type type)
		{
			return (type.IsPrimitive && (object)type != typeof(bool)) || (object)type == typeof(decimal);
		}

		public override void RefreshUIForValue()
		{
			valueInput.Text = Value.ToString();
			if (!((Component)valueInput.Component).gameObject.activeSelf)
			{
				((Component)valueInput.Component).gameObject.SetActive(true);
			}
			if (Object.op_Implicit((Object)(object)slider))
			{
				slider.value = (float)Convert.ChangeType(Value, typeof(float));
			}
		}

		internal void SetValueFromInput()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Value = ParseMethod.Invoke(null, new object[1] { valueInput.Text });
				ConfigDescription description = Owner.RefConfig.Description;
				AcceptableValueBase val = ((description != null) ? description.AcceptableValues : null);
				if (val != null && !val.IsValid(Value))
				{
					throw new Exception();
				}
				Owner.SetValueFromIValue();
				RefreshUIForValue();
				((Graphic)valueInput.Component.textComponent).color = Color.white;
			}
			catch
			{
				((Graphic)valueInput.Component.textComponent).color = Color.red;
			}
		}

		public override void ConstructUI(GameObject parent)
		{
			base.ConstructUI(parent);
			valueInput = UIFactory.CreateInputField(mainContent, "InteractiveNumberInput", "...");
			UIFactory.SetLayoutElement(((Component)valueInput.Component).gameObject, (int?)120, (int?)25, (int?)0, (int?)null, (int?)null, (int?)null, (bool?)null);
			((Component)valueInput.Component).gameObject.SetActive(false);
			valueInput.OnValueChanged += delegate
			{
				SetValueFromInput();
			};
			AcceptableValueBase acceptableValues = Owner.RefConfig.Description.AcceptableValues;
			if (acceptableValues != null)
			{
				Type type = typeof(AcceptableValueRange<>).MakeGenericType(acceptableValues.ValueType);
				object value = AccessTools.Property(type, "MinValue").GetValue(acceptableValues, null);
				object value2 = AccessTools.Property(type, "MaxValue").GetValue(acceptableValues, null);
				Text mainLabel = Owner.mainLabel;
				mainLabel.text = mainLabel.text + " <color=grey><i>[" + value.ToString() + " - " + value2.ToString() + "]</i></color>";
				GameObject val2 = UIFactory.CreateSlider(mainContent, "ValueSlider", ref slider);
				UIFactory.SetLayoutElement(val2, (int?)250, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
				slider.minValue = (float)Convert.ChangeType(value, typeof(float));
				slider.maxValue = (float)Convert.ChangeType(value2, typeof(float));
				slider.value = (float)Convert.ChangeType(Value, typeof(float));
				((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)delegate(float val)
				{
					Value = Convert.ChangeType(val, FallbackType);
					Owner.SetValueFromIValue();
					valueInput.Text = Value.ToString();
				});
			}
		}
	}
	public class InteractiveString : InteractiveValue
	{
		internal InputFieldRef valueInput;

		internal GameObject hiddenObj;

		internal Text placeholderText;

		public InteractiveString(object value, Type valueType)
			: base(value, valueType)
		{
		}

		public override bool SupportsType(Type type)
		{
			return (object)type == typeof(string);
		}

		public override void RefreshUIForValue()
		{
			if (!hiddenObj.gameObject.activeSelf)
			{
				hiddenObj.gameObject.SetActive(true);
			}
			if (!string.IsNullOrEmpty((string)Value))
			{
				string text = (string)Value;
				if (text.Length > 15000)
				{
					text = text.Substring(0, 15000);
				}
				valueInput.Text = text;
				placeholderText.text = text;
			}
			else
			{
				string text2 = ((Value == null) ? "null" : "empty");
				valueInput.Text = "";
				placeholderText.text = text2;
			}
		}

		internal void SetValueFromInput()
		{
			Value = valueInput.Text;
			Owner.SetValueFromIValue();
		}

		public override void ConstructUI(GameObject parent)
		{
			//IL_002a: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			base.ConstructUI(parent);
			hiddenObj = ((Component)UIFactory.CreateLabel(mainContent, "HiddenLabel", "", (TextAnchor)3, default(Color), true, 14)).gameObject;
			hiddenObj.SetActive(false);
			Text hiddenText = hiddenObj.GetComponent<Text>();
			((Graphic)hiddenText).color = Color.clear;
			hiddenText.fontSize = 14;
			((Graphic)hiddenText).raycastTarget = false;
			hiddenText.supportRichText = false;
			ContentSizeFitter val2 = hiddenObj.AddComponent<ContentSizeFitter>();
			val2.verticalFit = (FitMode)2;
			GameObject obj = hiddenObj;
			int? num = 25;
			int? num2 = 500;
			UIFactory.SetLayoutElement(obj, (int?)250, num, (int?)9000, num2, (int?)null, (int?)null, (bool?)null);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(hiddenObj, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null);
			valueInput = UIFactory.CreateInputField(hiddenObj, "StringInputField", "...");
			UIFactory.SetLayoutElement(((Component)valueInput.Component).gameObject, (int?)120, (int?)25, (int?)5000, (int?)5000, (int?)null, (int?)null, (bool?)null);
			valueInput.Component.lineType = (LineType)2;
			placeholderText = ((Component)valueInput.Component.placeholder).GetComponent<Text>();
			placeholderText.supportRichText = false;
			valueInput.Component.textComponent.supportRichText = false;
			valueInput.OnValueChanged += delegate(string val)
			{
				hiddenText.text = val ?? "";
				LayoutRebuilder.ForceRebuildLayoutImmediate(Owner.ContentRect);
				SetValueFromInput();
			};
			RefreshUIForValue();
		}
	}
	public class InteractiveTomlObject : InteractiveValue
	{
		internal InputFieldRef valueInput;

		internal GameObject hiddenObj;

		internal Text placeholderText;

		public InteractiveTomlObject(object value, Type valueType)
			: base(value, valueType)
		{
		}

		public override bool SupportsType(Type type)
		{
			return true;
		}

		public override void OnValueUpdated()
		{
			base.OnValueUpdated();
			try
			{
				valueInput.Text = TomlTypeConverter.ConvertToString(Value, FallbackType);
				placeholderText.text = valueInput.Text;
			}
			catch
			{
				ConfigManager.LogSource.LogWarning((object)("Unable to edit entry '" + Owner.RefConfig.Definition.Key + "' due to an error with the Toml converter!"));
			}
		}

		internal void SetValueFromInput()
		{
			//IL_005a: 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)
			try
			{
				Value = TomlTypeConverter.ConvertToValue(valueInput.Text, FallbackType);
				Owner.SetValueFromIValue();
				((Graphic)valueInput.Component.textComponent).color = Color.white;
			}
			catch
			{
				((Graphic)valueInput.Component.textComponent).color = Color.red;
			}
		}

		public override void RefreshUIForValue()
		{
			if (!hiddenObj.gameObject.activeSelf)
			{
				hiddenObj.gameObject.SetActive(true);
			}
		}

		public override void ConstructUI(GameObject parent)
		{
			//IL_002a: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			base.ConstructUI(parent);
			hiddenObj = ((Component)UIFactory.CreateLabel(mainContent, "HiddenLabel", "", (TextAnchor)3, default(Color), true, 14)).gameObject;
			hiddenObj.SetActive(false);
			Text hiddenText = hiddenObj.GetComponent<Text>();
			((Graphic)hiddenText).color = Color.clear;
			hiddenText.fontSize = 14;
			((Graphic)hiddenText).raycastTarget = false;
			hiddenText.supportRichText = false;
			ContentSizeFitter val2 = hiddenObj.AddComponent<ContentSizeFitter>();
			val2.verticalFit = (FitMode)2;
			GameObject obj = hiddenObj;
			int? num = 25;
			int? num2 = 500;
			UIFactory.SetLayoutElement(obj, (int?)250, num, (int?)9000, num2, (int?)null, (int?)null, (bool?)null);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(hiddenObj, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)null, (int?)null, (int?)null, (int?)null, (int?)null, (TextAnchor?)null);
			valueInput = UIFactory.CreateInputField(hiddenObj, "StringInputField", "...");
			UIFactory.SetLayoutElement(((Component)valueInput.Component).gameObject, (int?)120, (int?)25, (int?)5000, (int?)5000, (int?)null, (int?)null, (bool?)null);
			valueInput.Component.lineType = (LineType)2;
			placeholderText = ((Component)valueInput.Component.placeholder).GetComponent<Text>();
			placeholderText.supportRichText = false;
			valueInput.Component.textComponent.supportRichText = false;
			OnValueUpdated();
			valueInput.OnValueChanged += delegate(string val)
			{
				hiddenText.text = val ?? "";
				LayoutRebuilder.ForceRebuildLayoutImmediate(Owner.ContentRect);
				SetValueFromInput();
			};
		}
	}
	public abstract class InteractiveValue
	{
		private static readonly HashSet<Type> customIValueTypes = new HashSet<Type>();

		private static readonly List<InteractiveValue> customIValueInstances = new List<InteractiveValue>();

		public CachedConfigEntry Owner;

		public object Value;

		public readonly Type FallbackType;

		public bool UIConstructed;

		protected internal GameObject mainContentParent;

		protected internal GameObject subContentParent;

		protected internal GameObject mainContent;

		protected internal ButtonRef subExpandBtn;

		protected internal bool subContentConstructed;

		public virtual bool HasSubContent => false;

		public virtual bool SubContentWanted => false;

		public static void RegisterIValueType<T>() where T : InteractiveValue
		{
			if (!customIValueTypes.Contains(typeof(T)))
			{
				customIValueInstances.Add((T)Activator.CreateInstance(typeof(T), null, typeof(object)));
				customIValueTypes.Add(typeof(T));
			}
		}

		public static Type GetIValueForType(Type type)
		{
			if ((object)type == typeof(bool))
			{
				return typeof(InteractiveBool);
			}
			if (type.IsPrimitive || typeof(decimal).IsAssignableFrom(type))
			{
				return typeof(InteractiveNumber);
			}
			if ((object)type == typeof(string))
			{
				return typeof(InteractiveString);
			}
			if ((object)type == typeof(KeyCode) || type.FullName == "UnityEngine.InputSystem.Key")
			{
				return typeof(InteractiveKeycode);
			}
			if (typeof(Enum).IsAssignableFrom(type))
			{
				object[] customAttributes = type.GetCustomAttributes(typeof(FlagsAttribute), inherit: true);
				if (customAttributes != null && customAttributes.Any())
				{
					return typeof(InteractiveFlags);
				}
				return typeof(InteractiveEnum);
			}
			if ((object)type == typeof(Color) || (object)type == typeof(Color32))
			{
				return typeof(InteractiveColor);
			}
			if (InteractiveFloatStruct.IsTypeSupported(type))
			{
				return typeof(InteractiveFloatStruct);
			}
			InteractiveValue interactiveValue = customIValueInstances.FirstOrDefault((InteractiveValue it) => it.SupportsType(type));
			if (interactiveValue != null)
			{
				return interactiveValue.GetType();
			}
			return typeof(InteractiveTomlObject);
		}

		public static InteractiveValue Create(object value, Type fallbackType)
		{
			Type type = ReflectionExtensions.GetActualType(value) ?? fallbackType;
			Type iValueForType = GetIValueForType(type);
			return (InteractiveValue)Activator.CreateInstance(iValueForType, value, type);
		}

		public InteractiveValue(object value, Type valueType)
		{
			Value = value;
			FallbackType = valueType;
		}

		public virtual bool SupportsType(Type type)
		{
			return true;
		}

		public virtual void OnValueUpdated()
		{
			if (!UIConstructed)
			{
				ConstructUI(mainContentParent);
			}
			RefreshUIForValue();
		}

		public virtual void RefreshUIForValue()
		{
		}

		public void RefreshSubContentState()
		{
			if (HasSubContent)
			{
				if (((Component)subExpandBtn.Component).gameObject.activeSelf != SubContentWanted)
				{
					((Component)subExpandBtn.Component).gameObject.SetActive(SubContentWanted);
				}
				if (!SubContentWanted && subContentParent.activeSelf)
				{
					ToggleSubcontent();
				}
			}
		}

		public virtual void ConstructSubcontent()
		{
			subContentConstructed = true;
		}

		public virtual void DestroySubContent()
		{
			if (Object.op_Implicit((Object)(object)subContentParent) && HasSubContent)
			{
				for (int i = 0; i < subContentParent.transform.childCount; i++)
				{
					Transform child = subContentParent.transform.GetChild(i);
					if (Object.op_Implicit((Object)(object)child))
					{
						Object.Destroy((Object)(object)((Component)child).gameObject);
					}
				}
			}
			subContentConstructed = false;
		}

		public void ToggleSubcontent()
		{
			if (!subContentParent.activeSelf)
			{
				subContentParent.SetActive(true);
				subContentParent.transform.SetAsLastSibling();
				subExpandBtn.ButtonText.text = "▼ Click to hide";
			}
			else
			{
				subContentParent.SetActive(false);
				subExpandBtn.ButtonText.text = "▲ Expand to edit";
			}
			OnToggleSubcontent(subContentParent.activeSelf);
			RefreshSubContentState();
		}

		protected internal virtual void OnToggleSubcontent(bool toggle)
		{
			if (!subContentConstructed)
			{
				ConstructSubcontent();
			}
		}

		public virtual void ConstructUI(GameObject parent)
		{
			//IL_0026: 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_0041: 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)
			UIConstructed = true;
			mainContent = UIFactory.CreateHorizontalGroup(parent, "InteractiveValue_" + GetType().Name, false, false, true, true, 4, default(Vector4), new Color(1f, 1f, 1f, 0f), (TextAnchor?)(TextAnchor)0);
			RectTransform component = mainContent.GetComponent<RectTransform>();
			component.SetSizeWithCurrentAnchors((Axis)1, 25f);
			GameObject obj = mainContent;
			int? num = 9000;
			UIFactory.SetLayoutElement(obj, (int?)175, (int?)25, num, (int?)0, (int?)null, (int?)null, (bool?)null);
			if (HasSubContent)
			{
				subExpandBtn = UIFactory.CreateButton(mainContent, "ExpandSubcontentButton", "▲ Expand to edit", (Color?)new Color(0.3f, 0.3f, 0.3f));
				ButtonRef obj2 = subExpandBtn;
				obj2.OnClick = (Action)Delegate.Combine(obj2.OnClick, new Action(ToggleSubcontent));
				GameObject gameObject = ((Component)subExpandBtn.Component).gameObject;
				num = 25;
				UIFactory.SetLayoutElement(gameObject, (int?)120, num, (int?)0, (int?)0, (int?)null, (int?)null, (bool?)null);
			}
		}
	}
	public class InteractiveValueList : InteractiveValue
	{
		internal IEnumerable<object> acceptableValues;

		internal Dropdown dropdown;

		internal Dictionary<object, OptionData> dropdownOptions = new Dictionary<object, OptionData>();

		public InteractiveValueList(object value, Type valueType)
			: base(value, valueType)
		{
		}

		public override bool SupportsType(Type type)
		{
			return type.IsEnum;
		}

		internal void GetAcceptableValues()
		{
			if (acceptableValues == null)
			{
				AcceptableValueBase val = Owner.RefConfig.Description.AcceptableValues;
				PropertyInfo property = ((object)val).GetType().GetProperty("AcceptableValues");
				acceptableValues = (property.GetValue(val, null) as IList).Cast<object>();
			}
		}

		public override void OnValueUpdated()
		{
			GetAcceptableValues();
			base.OnValueUpdated();
		}

		public override void RefreshUIForValue()
		{
			base.RefreshUIForValue();
			if (dropdownOptions.ContainsKey(Value))
			{
				dropdown.value = dropdown.options.IndexOf(dropdownOptions[Value]);
			}
		}

		private void SetValueFromDropdown()
		{
			object obj = acceptableValues.ElementAt(dropdown.value);
			if (obj != null)
			{
				Value = obj;
				Owner.SetValueFromIValue();
				RefreshUIForValue();
			}
		}

		public override void ConstructUI(GameObject parent)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			base.ConstructUI(parent);
			GameObject val2 = UIFactory.CreateDropdown(mainContent, "InteractiveValueList", ref dropdown, "", 14, (Action<int>)null, (string[])null);
			UIFactory.SetLayoutElement(val2, (int?)400, (int?)25, (int?)null, (int?)null, (int?)null, (int?)null, (bool?)null);
			((UnityEvent<int>)(object)dropdown.onValueChanged).AddListener((UnityAction<int>)delegate
			{
				SetValueFromDropdown();
			});
			foreach (object acceptableValue in acceptableValues)
			{
				OptionData val3 = new OptionData
				{
					text = acceptableValue.ToString()
				};
				dropdown.options.Add(val3);
				dropdownOptions.Add(acceptableValue, val3);
			}
		}
	}
}
namespace ConfigManager.Utility
{
	internal sealed class ConfigurationManagerAttributes
	{
		public bool? ShowRangeAsPercent;

		public Action<ConfigEntryBase> CustomDrawer;

		public bool? Browsable;

		public string Category;

		public object DefaultValue;

		public bool? HideDefaultButton;

		public bool? HideSettingName;

		public string Description;

		public string DispName;

		public int? Order;

		public bool? ReadOnly;

		public bool? IsAdvanced;

		public Func<object, string> ObjToStr;

		public Func<string, object> StrToObj;
	}
}

BepInEx/plugins/Obeliskial Essentials.dll

Decompiled 7 months ago
using System;
using System.Collections;
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 System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Paradox;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UniverseLib;
using UniverseLib.Config;
using UniverseLib.UI;
using UniverseLib.UI.Models;
using UniverseLib.UI.Panels;
using UniverseLib.UI.Widgets;

[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("com.stiffmeds.obeliskialessentials")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Essential reference classes and methods for Across the Obelisk modding.")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0")]
[assembly: AssemblyProduct("Obeliskial Essentials")]
[assembly: AssemblyTitle("com.stiffmeds.obeliskialessentials")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.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;
		}
	}
}
public class SnapshotCamera : MonoBehaviour
{
	private struct GameObjectStateSnapshot
	{
		private GameObject gameObject;

		private Vector3 position;

		private Quaternion rotation;

		private Vector3 scale;

		private Dictionary<GameObject, int> layers;

		public GameObjectStateSnapshot(GameObject gameObject)
		{
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			this.gameObject = gameObject;
			position = gameObject.transform.position;
			rotation = gameObject.transform.rotation;
			scale = gameObject.transform.localScale;
			layers = new Dictionary<GameObject, int>();
			Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				layers.Add(((Component)val).gameObject, ((Component)val).gameObject.layer);
			}
		}

		public void Restore()
		{
			//IL_000d: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			gameObject.transform.position = position;
			gameObject.transform.rotation = rotation;
			gameObject.transform.localScale = scale;
			foreach (KeyValuePair<GameObject, int> layer in layers)
			{
				layer.Key.layer = layer.Value;
			}
		}
	}

	private Camera cam;

	private int layer;

	public Vector3 defaultPositionOffset = new Vector3(0f, 0f, 1f);

	public Vector3 defaultRotation = new Vector3(0f, 0f, 0f);

	public Vector3 defaultScale = new Vector3(1f, 1f, 1f);

	private SnapshotCamera()
	{
	}//IL_0010: Unknown result type (might be due to invalid IL or missing references)
	//IL_0015: 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_002f: 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_0049: Unknown result type (might be due to invalid IL or missing references)


	public static SnapshotCamera MakeSnapshotCamera(string layer, string name = "Snapshot Camera")
	{
		return MakeSnapshotCamera(LayerMask.NameToLayer(layer), name);
	}

	public static SnapshotCamera MakeSnapshotCamera(int layer = 5, string name = "Snapshot Camera")
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		if (layer < 0 || layer > 31)
		{
			throw new ArgumentOutOfRangeException("layer", "layer argument must specify a valid layer between 0 and 31");
		}
		GameObject val = new GameObject(name);
		Camera val2 = val.AddComponent<Camera>();
		val2.cullingMask = 1 << layer;
		val2.orthographic = true;
		val2.orthographicSize = 1f;
		val2.clearFlags = (CameraClearFlags)2;
		val2.backgroundColor = Color.clear;
		val2.nearClipPlane = 0.1f;
		((Behaviour)val2).enabled = false;
		SnapshotCamera snapshotCamera = val.AddComponent<SnapshotCamera>();
		snapshotCamera.cam = val2;
		snapshotCamera.layer = layer;
		return snapshotCamera;
	}

	private static string SanitizeFilename(string dirty)
	{
		string arg = Regex.Escape(new string(Path.GetInvalidFileNameChars()));
		string pattern = string.Format("([{0}]*\\.+$)|([{0}]+)", arg);
		return Regex.Replace(dirty, pattern, "_");
	}

	public static FileInfo SavePNG(byte[] bytes, string filename = "", string directory = "")
	{
		directory = ((directory != "") ? Directory.CreateDirectory(directory).FullName : Directory.CreateDirectory(Path.Combine(Application.dataPath, "../Snapshots")).FullName);
		filename = ((filename != "") ? (SanitizeFilename(filename) + ".png") : (DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff") + ".png"));
		string text = Path.Combine(directory, filename);
		File.WriteAllBytes(text, bytes);
		return new FileInfo(text);
	}

	public static FileInfo SavePNG(Texture2D tex, string filename = "", string directory = "")
	{
		return SavePNG(ImageConversion.EncodeToPNG(tex), filename, directory);
	}

	private void SetLayersRecursively(GameObject gameObject)
	{
		Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			((Component)val).gameObject.layer = layer;
		}
	}

	private GameObjectStateSnapshot PrepareObject(GameObject gameObject, Vector3 positionOffset, Quaternion rotation, Vector3 scale)
	{
		//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_001b: 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)
		GameObjectStateSnapshot result = new GameObjectStateSnapshot(gameObject);
		gameObject.transform.position = ((Component)this).transform.position + positionOffset;
		gameObject.transform.rotation = rotation;
		gameObject.transform.localScale = scale;
		SetLayersRecursively(gameObject);
		return result;
	}

	private GameObject PreparePrefab(GameObject prefab, Vector3 positionOffset, Quaternion rotation, Vector3 scale)
	{
		//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)
		//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_0020: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position + positionOffset, rotation);
		val.transform.localScale = scale;
		SetLayersRecursively(val);
		return val;
	}

	public Texture2D TakeObjectSnapshot(GameObject gameObject, int width = 128, int height = 128)
	{
		//IL_0003: 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)
		//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_001a: Unknown result type (might be due to invalid IL or missing references)
		return TakeObjectSnapshot(gameObject, Color.clear, defaultPositionOffset, Quaternion.Euler(defaultRotation), defaultScale, width, height);
	}

	public Texture2D TakeObjectSnapshot(GameObject gameObject, Color backgroundColor, int width = 128, int height = 128)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0016: Unknown result type (might be due to invalid IL or missing references)
		return TakeObjectSnapshot(gameObject, backgroundColor, defaultPositionOffset, Quaternion.Euler(defaultRotation), defaultScale, width, height);
	}

	public Texture2D TakeObjectSnapshot(GameObject gameObject, Vector3 positionOffset, Quaternion rotation, Vector3 scale, int width = 128, int height = 128)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return TakeObjectSnapshot(gameObject, Color.clear, positionOffset, rotation, scale, width, height);
	}

	public Texture2D TakeObjectSnapshot(GameObject gameObject, Color backgroundColor, Vector3 positionOffset, Quaternion rotation, Vector3 scale, int width = 128, int height = 128)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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)
		if ((Object)(object)gameObject == (Object)null)
		{
			throw new ArgumentNullException("gameObject");
		}
		Scene scene = gameObject.scene;
		if (((Scene)(ref scene)).name == null)
		{
			throw new ArgumentException("gameObject parameter must be an instantiated GameObject! If you want to use a prefab directly, use TakePrefabSnapshot instead.", "gameObject");
		}
		GameObjectStateSnapshot gameObjectStateSnapshot = PrepareObject(gameObject, positionOffset, rotation, scale);
		Texture2D result = TakeSnapshot(backgroundColor, width, height);
		gameObjectStateSnapshot.Restore();
		return result;
	}

	public Texture2D TakePrefabSnapshot(GameObject prefab, int width = 128, int height = 128)
	{
		//IL_0003: 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)
		//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_001a: Unknown result type (might be due to invalid IL or missing references)
		return TakePrefabSnapshot(prefab, Color.clear, defaultPositionOffset, Quaternion.Euler(defaultRotation), defaultScale, width, height);
	}

	public Texture2D TakePrefabSnapshot(GameObject prefab, Color backgroundColor, int width = 128, int height = 128)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0016: Unknown result type (might be due to invalid IL or missing references)
		return TakePrefabSnapshot(prefab, backgroundColor, defaultPositionOffset, Quaternion.Euler(defaultRotation), defaultScale, width, height);
	}

	public Texture2D TakePrefabSnapshot(GameObject prefab, Vector3 positionOffset, Quaternion rotation, Vector3 scale, int width = 128, int height = 128)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		return TakePrefabSnapshot(prefab, Color.clear, positionOffset, rotation, scale, width, height);
	}

	public Texture2D TakePrefabSnapshot(GameObject prefab, Color backgroundColor, Vector3 positionOffset, Quaternion rotation, Vector3 scale, int width = 128, int height = 128)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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)
		if ((Object)(object)prefab == (Object)null)
		{
			throw new ArgumentNullException("prefab");
		}
		Scene scene = prefab.scene;
		if (((Scene)(ref scene)).name != null)
		{
			throw new ArgumentException("prefab parameter must be a prefab! If you want to use an instance, use TakeObjectSnapshot instead.", "prefab");
		}
		GameObject val = PreparePrefab(prefab, positionOffset, rotation, scale);
		Texture2D result = TakeSnapshot(backgroundColor, width, height);
		Object.DestroyImmediate((Object)(object)val);
		return result;
	}

	private Texture2D TakeSnapshot(Color backgroundColor, int width, int height)
	{
		//IL_0007: 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_006e: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		cam.backgroundColor = backgroundColor;
		cam.targetTexture = RenderTexture.GetTemporary(width, height, 24);
		cam.Render();
		RenderTexture active = RenderTexture.active;
		RenderTexture.active = cam.targetTexture;
		Texture2D val = new Texture2D(((Texture)cam.targetTexture).width, ((Texture)cam.targetTexture).height, (TextureFormat)5, false);
		val.ReadPixels(new Rect(0f, 0f, (float)((Texture)cam.targetTexture).width, (float)((Texture)cam.targetTexture).height), 0, 0);
		val.Apply(false);
		RenderTexture.active = active;
		cam.targetTexture = null;
		RenderTexture.ReleaseTemporary(cam.targetTexture);
		return val;
	}
}
namespace Obeliskial_Essentials
{
	[HarmonyPatch]
	internal class CardDescription
	{
		private static string medsColorUpgradePlain = "5E3016";

		private static string medsColorUpgradeGold = "875700";

		private static string medsColorUpgradeBlue = "215382";

		private static string medsColorUpgradeRare = "7F15A6";

		[HarmonyPrefix]
		[HarmonyPatch(typeof(CardData), "SetDescriptionNew")]
		public static bool SetDescriptionNewPrefix(ref CardData __instance, bool forceDescription = false, Character character = null, bool includeInSearch = true)
		{
			//IL_53b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_53ba: Invalid comparison between Unknown and I4
			//IL_5420: Unknown result type (might be due to invalid IL or missing references)
			//IL_542d: Unknown result type (might be due to invalid IL or missing references)
			//IL_5434: Invalid comparison between Unknown and I4
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Invalid comparison between Unknown and I4
			//IL_54a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_545d: 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_0243: Invalid comparison between Unknown and I4
			//IL_54ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_54b5: Invalid comparison between Unknown and I4
			//IL_5539: Unknown result type (might be due to invalid IL or missing references)
			//IL_54de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac4: Invalid comparison between Unknown and I4
			//IL_5546: Unknown result type (might be due to invalid IL or missing references)
			//IL_554d: Invalid comparison between Unknown and I4
			//IL_0b1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b22: Invalid comparison between Unknown and I4
			//IL_0aed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1a: Invalid comparison between Unknown and I4
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0495: Invalid comparison between Unknown and I4
			//IL_5576: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c91: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c97: Invalid comparison between Unknown and I4
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_5658: Unknown result type (might be due to invalid IL or missing references)
			//IL_565e: Invalid comparison between Unknown and I4
			//IL_56b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_56bc: Invalid comparison between Unknown and I4
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Invalid comparison between Unknown and I4
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Invalid comparison between Unknown and I4
			//IL_571e: Unknown result type (might be due to invalid IL or missing references)
			//IL_5724: Invalid comparison between Unknown and I4
			//IL_1020: Unknown result type (might be due to invalid IL or missing references)
			//IL_089b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a1: Invalid comparison between Unknown and I4
			//IL_077e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Invalid comparison between Unknown and I4
			//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Invalid comparison between Unknown and I4
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bf: Invalid comparison between Unknown and I4
			//IL_577c: Unknown result type (might be due to invalid IL or missing references)
			//IL_5782: Invalid comparison between Unknown and I4
			//IL_1029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0926: Unknown result type (might be due to invalid IL or missing references)
			//IL_092c: Invalid comparison between Unknown and I4
			//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b2: Invalid comparison between Unknown and I4
			//IL_07aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Invalid comparison between Unknown and I4
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0705: Invalid comparison between Unknown and I4
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_57e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_57eb: Invalid comparison between Unknown and I4
			//IL_1032: Unknown result type (might be due to invalid IL or missing references)
			//IL_1038: Invalid comparison between Unknown and I4
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0973: Invalid comparison between Unknown and I4
			//IL_0937: Unknown result type (might be due to invalid IL or missing references)
			//IL_093d: Invalid comparison between Unknown and I4
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ed: Invalid comparison between Unknown and I4
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dc: Invalid comparison between Unknown and I4
			//IL_0729: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Invalid comparison between Unknown and I4
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0715: Invalid comparison between Unknown and I4
			//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Invalid comparison between Unknown and I4
			//IL_5851: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e2: Invalid comparison between Unknown and I4
			//IL_097e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0984: Invalid comparison between Unknown and I4
			//IL_0950: Unknown result type (might be due to invalid IL or missing references)
			//IL_0956: Invalid comparison between Unknown and I4
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_073f: Invalid comparison between Unknown and I4
			//IL_585e: Unknown result type (might be due to invalid IL or missing references)
			//IL_5865: Invalid comparison between Unknown and I4
			//IL_13a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_13aa: Invalid comparison between Unknown and I4
			//IL_09ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f3: Invalid comparison between Unknown and I4
			//IL_09c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c8: Invalid comparison between Unknown and I4
			//IL_098f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0995: Invalid comparison between Unknown and I4
			//IL_0743: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0c: Invalid comparison between Unknown and I4
			//IL_09a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ae: Invalid comparison between Unknown and I4
			//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0805: Invalid comparison between Unknown and I4
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Invalid comparison between Unknown and I4
			//IL_58d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_588e: Unknown result type (might be due to invalid IL or missing references)
			//IL_58df: Unknown result type (might be due to invalid IL or missing references)
			//IL_58e6: Invalid comparison between Unknown and I4
			//IL_5942: Unknown result type (might be due to invalid IL or missing references)
			//IL_590f: Unknown result type (might be due to invalid IL or missing references)
			//IL_594f: Unknown result type (might be due to invalid IL or missing references)
			//IL_5956: Invalid comparison between Unknown and I4
			//IL_59b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_59b9: Invalid comparison between Unknown and I4
			//IL_597f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1773: Unknown result type (might be due to invalid IL or missing references)
			//IL_5b70: Unknown result type (might be due to invalid IL or missing references)
			//IL_179f: Unknown result type (might be due to invalid IL or missing references)
			//IL_17a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1896: Unknown result type (might be due to invalid IL or missing references)
			//IL_1810: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b08: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b0e: Invalid comparison between Unknown and I4
			//IL_19e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1994: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ab0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a64: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cd1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1cd7: Invalid comparison between Unknown and I4
			//IL_1ce5: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ceb: Invalid comparison between Unknown and I4
			//IL_1cdb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ce1: Invalid comparison between Unknown and I4
			//IL_638c: Unknown result type (might be due to invalid IL or missing references)
			//IL_6392: Invalid comparison between Unknown and I4
			//IL_63d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_6423: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d74: Unknown result type (might be due to invalid IL or missing references)
			//IL_6430: Unknown result type (might be due to invalid IL or missing references)
			//IL_6437: Invalid comparison between Unknown and I4
			//IL_1d7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1d83: Invalid comparison between Unknown and I4
			//IL_6676: Unknown result type (might be due to invalid IL or missing references)
			//IL_6486: Unknown result type (might be due to invalid IL or missing references)
			//IL_648c: Invalid comparison between Unknown and I4
			//IL_643f: Unknown result type (might be due to invalid IL or missing references)
			//IL_6446: Invalid comparison between Unknown and I4
			//IL_6683: Unknown result type (might be due to invalid IL or missing references)
			//IL_668a: Invalid comparison between Unknown and I4
			//IL_64c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_644e: Unknown result type (might be due to invalid IL or missing references)
			//IL_6455: Invalid comparison between Unknown and I4
			//IL_1dc0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1dc6: Invalid comparison between Unknown and I4
			//IL_266c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1dca: Unknown result type (might be due to invalid IL or missing references)
			//IL_1dd0: Invalid comparison between Unknown and I4
			//IL_1dd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1dda: Invalid comparison between Unknown and I4
			//IL_1eea: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ef0: Invalid comparison between Unknown and I4
			//IL_26e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_6947: Unknown result type (might be due to invalid IL or missing references)
			//IL_694d: Invalid comparison between Unknown and I4
			//IL_2723: Unknown result type (might be due to invalid IL or missing references)
			//IL_272a: Unknown result type (might be due to invalid IL or missing references)
			//IL_6988: Unknown result type (might be due to invalid IL or missing references)
			//IL_698f: Invalid comparison between Unknown and I4
			//IL_2761: Unknown result type (might be due to invalid IL or missing references)
			//IL_69ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_69d1: Invalid comparison between Unknown and I4
			//IL_27e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_2032: Unknown result type (might be due to invalid IL or missing references)
			//IL_2038: Invalid comparison between Unknown and I4
			//IL_69d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_69e0: Invalid comparison between Unknown and I4
			//IL_214c: Unknown result type (might be due to invalid IL or missing references)
			//IL_2152: Invalid comparison between Unknown and I4
			//IL_2266: Unknown result type (might be due to invalid IL or missing references)
			//IL_226c: Invalid comparison between Unknown and I4
			//IL_6ab8: Unknown result type (might be due to invalid IL or missing references)
			//IL_6abf: Invalid comparison between Unknown and I4
			//IL_2395: Unknown result type (might be due to invalid IL or missing references)
			//IL_239b: Invalid comparison between Unknown and I4
			//IL_6afa: Unknown result type (might be due to invalid IL or missing references)
			//IL_6b01: Invalid comparison between Unknown and I4
			//IL_6bab: Unknown result type (might be due to invalid IL or missing references)
			//IL_6bb2: Invalid comparison between Unknown and I4
			//IL_6bed: Unknown result type (might be due to invalid IL or missing references)
			//IL_6bf4: Invalid comparison between Unknown and I4
			//IL_6c2f: Unknown result type (might be due to invalid IL or missing references)
			//IL_6c36: Invalid comparison between Unknown and I4
			//IL_7154: Unknown result type (might be due to invalid IL or missing references)
			//IL_715a: Invalid comparison between Unknown and I4
			//IL_6c71: Unknown result type (might be due to invalid IL or missing references)
			//IL_6c78: Invalid comparison between Unknown and I4
			//IL_6cb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_6cba: Invalid comparison between Unknown and I4
			//IL_7195: Unknown result type (might be due to invalid IL or missing references)
			//IL_6cf5: Unknown result type (might be due to invalid IL or missing references)
			//IL_6cfc: Invalid comparison between Unknown and I4
			//IL_7217: Unknown result type (might be due to invalid IL or missing references)
			//IL_6d37: Unknown result type (might be due to invalid IL or missing references)
			//IL_6d3d: Invalid comparison between Unknown and I4
			//IL_7224: Unknown result type (might be due to invalid IL or missing references)
			//IL_722b: Invalid comparison between Unknown and I4
			//IL_6dd1: Unknown result type (might be due to invalid IL or missing references)
			//IL_6dd7: Invalid comparison between Unknown and I4
			//IL_7233: Unknown result type (might be due to invalid IL or missing references)
			//IL_723a: Invalid comparison between Unknown and I4
			//IL_6e6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_6e72: Invalid comparison between Unknown and I4
			//IL_7242: Unknown result type (might be due to invalid IL or missing references)
			//IL_7249: Invalid comparison between Unknown and I4
			//IL_2990: Unknown result type (might be due to invalid IL or missing references)
			//IL_2bc0: Unknown result type (might be due to invalid IL or missing references)
			//IL_2bc6: Invalid comparison between Unknown and I4
			//IL_2a95: Unknown result type (might be due to invalid IL or missing references)
			//IL_2d9f: Unknown result type (might be due to invalid IL or missing references)
			//IL_2da5: Invalid comparison between Unknown and I4
			//IL_74e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_74eb: Invalid comparison between Unknown and I4
			//IL_7625: Unknown result type (might be due to invalid IL or missing references)
			//IL_762b: Invalid comparison between Unknown and I4
			//IL_752e: Unknown result type (might be due to invalid IL or missing references)
			//IL_7534: Invalid comparison between Unknown and I4
			//IL_2b23: Unknown result type (might be due to invalid IL or missing references)
			//IL_75bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_75c3: Invalid comparison between Unknown and I4
			//IL_754b: Unknown result type (might be due to invalid IL or missing references)
			//IL_7552: Invalid comparison between Unknown and I4
			//IL_76e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_76ef: Invalid comparison between Unknown and I4
			//IL_7732: Unknown result type (might be due to invalid IL or missing references)
			//IL_7738: Invalid comparison between Unknown and I4
			//IL_797d: Unknown result type (might be due to invalid IL or missing references)
			//IL_77c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_77cb: Invalid comparison between Unknown and I4
			//IL_774f: Unknown result type (might be due to invalid IL or missing references)
			//IL_7756: Invalid comparison between Unknown and I4
			//IL_3ba2: Unknown result type (might be due to invalid IL or missing references)
			//IL_32ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_32d0: Invalid comparison between Unknown and I4
			//IL_780e: Unknown result type (might be due to invalid IL or missing references)
			//IL_7814: Invalid comparison between Unknown and I4
			//IL_3313: Unknown result type (might be due to invalid IL or missing references)
			//IL_3319: Invalid comparison between Unknown and I4
			//IL_7854: Unknown result type (might be due to invalid IL or missing references)
			//IL_785a: Invalid comparison between Unknown and I4
			//IL_335c: Unknown result type (might be due to invalid IL or missing references)
			//IL_3362: Invalid comparison between Unknown and I4
			//IL_33e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_33ec: Invalid comparison between Unknown and I4
			//IL_3c2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_33a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_33a8: Invalid comparison between Unknown and I4
			//IL_341b: Unknown result type (might be due to invalid IL or missing references)
			//IL_3421: Invalid comparison between Unknown and I4
			//IL_2f6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_2f70: Invalid comparison between Unknown and I4
			//IL_7a75: Unknown result type (might be due to invalid IL or missing references)
			//IL_3450: Unknown result type (might be due to invalid IL or missing references)
			//IL_3456: Invalid comparison between Unknown and I4
			//IL_3483: Unknown result type (might be due to invalid IL or missing references)
			//IL_348a: Invalid comparison between Unknown and I4
			//IL_34bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_34c3: Invalid comparison between Unknown and I4
			//IL_3cb6: Unknown result type (might be due to invalid IL or missing references)
			//IL_34f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_34fc: Invalid comparison between Unknown and I4
			//IL_35dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_35e3: Invalid comparison between Unknown and I4
			//IL_2fac: Unknown result type (might be due to invalid IL or missing references)
			//IL_2fb2: Invalid comparison between Unknown and I4
			//IL_7ba4: Unknown result type (might be due to invalid IL or missing references)
			//IL_3500: Unknown result type (might be due to invalid IL or missing references)
			//IL_3507: Invalid comparison between Unknown and I4
			//IL_35e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_35ed: Invalid comparison between Unknown and I4
			//IL_3d41: Unknown result type (might be due to invalid IL or missing references)
			//IL_3d47: Invalid comparison between Unknown and I4
			//IL_35f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_35f7: Invalid comparison between Unknown and I4
			//IL_353c: Unknown result type (might be due to invalid IL or missing references)
			//IL_3543: Invalid comparison between Unknown and I4
			//IL_3636: Unknown result type (might be due to invalid IL or missing references)
			//IL_363c: Invalid comparison between Unknown and I4
			//IL_7d1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_7d22: Invalid comparison between Unknown and I4
			//IL_7cab: Unknown result type (might be due to invalid IL or missing references)
			//IL_35a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_35b0: Invalid comparison between Unknown and I4
			//IL_354e: Unknown result type (might be due to invalid IL or missing references)
			//IL_3554: Invalid comparison between Unknown and I4
			//IL_3640: Unknown result type (might be due to invalid IL or missing references)
			//IL_3646: Invalid comparison between Unknown and I4
			//IL_7fb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_7fb9: Invalid comparison between Unknown and I4
			//IL_364a: Unknown result type (might be due to invalid IL or missing references)
			//IL_3650: Invalid comparison between Unknown and I4
			//IL_7ffc: Unknown result type (might be due to invalid IL or missing references)
			//IL_8002: Invalid comparison between Unknown and I4
			//IL_3f07: Unknown result type (might be due to invalid IL or missing references)
			//IL_368f: Unknown result type (might be due to invalid IL or missing references)
			//IL_3695: Invalid comparison between Unknown and I4
			//IL_3939: Unknown result type (might be due to invalid IL or missing references)
			//IL_393f: Invalid comparison between Unknown and I4
			//IL_89a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_8089: Unknown result type (might be due to invalid IL or missing references)
			//IL_808f: Invalid comparison between Unknown and I4
			//IL_8015: Unknown result type (might be due to invalid IL or missing references)
			//IL_801b: Invalid comparison between Unknown and I4
			//IL_3699: Unknown result type (might be due to invalid IL or missing references)
			//IL_369f: Invalid comparison between Unknown and I4
			//IL_8152: Unknown result type (might be due to invalid IL or missing references)
			//IL_8158: Invalid comparison between Unknown and I4
			//IL_36a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_36a9: Invalid comparison between Unknown and I4
			//IL_821b: Unknown result type (might be due to invalid IL or missing references)
			//IL_8222: Invalid comparison between Unknown and I4
			//IL_3f9f: Unknown result type (might be due to invalid IL or missing references)
			//IL_36e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_36ee: Invalid comparison between Unknown and I4
			//IL_8a74: Unknown result type (might be due to invalid IL or missing references)
			//IL_82e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_82ec: Invalid comparison between Unknown and I4
			//IL_36f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_36f8: Invalid comparison between Unknown and I4
			//IL_8455: Unknown result type (might be due to invalid IL or missing references)
			//IL_845b: Invalid comparison between Unknown and I4
			//IL_36fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_3702: Invalid comparison between Unknown and I4
			//IL_85c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_85ca: Invalid comparison between Unknown and I4
			//IL_4037: Unknown result type (might be due to invalid IL or missing references)
			//IL_3741: Unknown result type (might be due to invalid IL or missing references)
			//IL_3748: Invalid comparison between Unknown and I4
			//IL_95ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_95fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_9603: Invalid comparison between Unknown and I4
			//IL_872f: Unknown result type (might be due to invalid IL or missing references)
			//IL_374c: Unknown result type (might be due to invalid IL or missing references)
			//IL_3753: Invalid comparison between Unknown and I4
			//IL_873c: Unknown result type (might be due to invalid IL or missing references)
			//IL_8742: Invalid comparison between Unknown and I4
			//IL_40c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_40c8: Invalid comparison between Unknown and I4
			//IL_3757: Unknown result type (might be due to invalid IL or missing references)
			//IL_375e: Invalid comparison between Unknown and I4
			//IL_8ee5: Unknown result type (might be due to invalid IL or missing references)
			//IL_8eeb: Invalid comparison between Unknown and I4
			//IL_379d: Unknown result type (might be due to invalid IL or missing references)
			//IL_37a4: Invalid comparison between Unknown and I4
			//IL_8f20: Unknown result type (might be due to invalid IL or missing references)
			//IL_4189: Unknown result type (might be due to invalid IL or missing references)
			//IL_37a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_37af: Invalid comparison between Unknown and I4
			//IL_37b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_37ba: Invalid comparison between Unknown and I4
			//IL_37f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_3800: Invalid comparison between Unknown and I4
			//IL_8895: Unknown result type (might be due to invalid IL or missing references)
			//IL_889c: Invalid comparison between Unknown and I4
			//IL_4213: Unknown result type (might be due to invalid IL or missing references)
			//IL_3804: Unknown result type (might be due to invalid IL or missing references)
			//IL_380b: Invalid comparison between Unknown and I4
			//IL_380f: Unknown result type (might be due to invalid IL or missing references)
			//IL_3816: Invalid comparison between Unknown and I4
			//IL_3855: Unknown result type (might be due to invalid IL or missing references)
			//IL_385c: Invalid comparison between Unknown and I4
			//IL_9269: Unknown result type (might be due to invalid IL or missing references)
			//IL_926f: Invalid comparison between Unknown and I4
			//IL_922b: Unknown result type (might be due to invalid IL or missing references)
			//IL_9231: Invalid comparison between Unknown and I4
			//IL_429d: Unknown result type (might be due to invalid IL or missing references)
			//IL_3860: Unknown result type (might be due to invalid IL or missing references)
			//IL_3867: Invalid comparison between Unknown and I4
			//IL_92b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_92b7: Invalid comparison between Unknown and I4
			//IL_9398: Unknown result type (might be due to invalid IL or missing references)
			//IL_939e: Invalid comparison between Unknown and I4
			//IL_3899: Unknown result type (might be due to invalid IL or missing references)
			//IL_38a0: Invalid comparison between Unknown and I4
			//IL_4499: Unknown result type (might be due to invalid IL or missing references)
			//IL_449f: Invalid comparison between Unknown and I4
			//IL_38a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_38ab: Invalid comparison between Unknown and I4
			//IL_456f: Unknown result type (might be due to invalid IL or missing references)
			//IL_45f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_467f: Unknown result type (might be due to invalid IL or missing references)
			//IL_470a: Unknown result type (might be due to invalid IL or missing references)
			//IL_4710: Invalid comparison between Unknown and I4
			//IL_4900: Unknown result type (might be due to invalid IL or missing references)
			//IL_4962: Unknown result type (might be due to invalid IL or missing references)
			//IL_4b81: Unknown result type (might be due to invalid IL or missing references)
			//IL_4f5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_4f64: Invalid comparison between Unknown and I4
			//IL_4c97: Unknown result type (might be due to invalid IL or missing references)
			//IL_4c9d: Invalid comparison between Unknown and I4
			//IL_4fa7: Unknown result type (might be due to invalid IL or missing references)
			//IL_4fad: Invalid comparison between Unknown and I4
			//IL_4d62: Unknown result type (might be due to invalid IL or missing references)
			//IL_4d68: Invalid comparison between Unknown and I4
			//IL_5028: Unknown result type (might be due to invalid IL or missing references)
			//IL_502e: Invalid comparison between Unknown and I4
			string value = Traverse.Create((object)__instance).Field("descriptionId").GetValue<string>();
			int value2 = Traverse.Create((object)__instance).Field("healPreCalculated").GetValue<int>();
			int value3 = Traverse.Create((object)__instance).Field("healSelfPreCalculated").GetValue<int>();
			int value4 = Traverse.Create((object)__instance).Field("enchantDamagePreCalculated").GetValue<int>();
			if (Essentials.medsCustomCardDescriptions.ContainsKey(__instance.Id))
			{
				__instance.DescriptionNormalized = Essentials.medsCustomCardDescriptions[__instance.Id];
			}
			else if (forceDescription || !Globals.Instance.CardsDescriptionNormalized.ContainsKey(__instance.Id))
			{
				StringBuilder stringBuilder = new StringBuilder();
				StringBuilder stringBuilder2 = new StringBuilder();
				string value5 = "<line-height=15%><br></line-height>";
				string value6 = "<color=#444><size=-.15>";
				string value7 = "</size></color>";
				string value8 = "<color=#5E3016><size=-.15>";
				int num = 0;
				if (value != "")
				{
					stringBuilder.Append(Functions.FormatStringCard(Texts.Instance.GetText(value, "")));
				}
				else if ((Object)(object)__instance.Item == (Object)null && (Object)(object)__instance.ItemEnchantment == (Object)null)
				{
					string text = "";
					string text2 = "";
					string text3 = "";
					float num2 = 0f;
					string text4 = "";
					bool flag = false;
					bool flag2 = false;
					bool flag3 = true;
					bool flag4 = false;
					StringBuilder stringBuilder3 = new StringBuilder();
					if (__instance.Damage > 0 || __instance.Damage2 > 0 || __instance.DamageSelf > 0 || __instance.DamageSelf2 > 0)
					{
						flag3 = false;
					}
					if (__instance.DrawCard != 0 && !__instance.DrawCardSpecialValueGlobal)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDraw", ""), medsColorTextArray("", medsNumFormat(__instance.DrawCard), medsSpriteText("card"))));
						stringBuilder.Append("<br>");
					}
					if ((int)__instance.SpecialValueGlobal == 17)
					{
						if ((int)__instance.DiscardCardPlace == 4)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsVanish", ""), medsColorTextArray("", "X", medsSpriteText("card"))));
						}
						else
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDiscard", ""), medsColorTextArray("", "X", medsSpriteText("card"))));
						}
						stringBuilder.Append("\n");
					}
					if (__instance.DrawCardSpecialValueGlobal)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDraw", ""), medsColorTextArray("aura", "X", medsSpriteText("card"))));
						stringBuilder.Append("<br>");
					}
					if (__instance.AddCard != 0)
					{
						string arg;
						if (__instance.AddCardId != "")
						{
							stringBuilder2.Append(medsColorTextArray("", medsNumFormat(__instance.AddCard), medsSpriteText("card")));
							CardData cardData = Globals.Instance.GetCardData(__instance.AddCardId, false);
							if ((Object)(object)cardData != (Object)null)
							{
								stringBuilder2.Append(medsColorFromCardDataRarity(cardData));
								stringBuilder2.Append(cardData.CardName);
								stringBuilder2.Append("</color>");
							}
							arg = stringBuilder2.ToString();
							stringBuilder2.Clear();
						}
						else
						{
							if (__instance.AddCardChoose > 0)
							{
								stringBuilder2.Append(medsColorTextArray("", medsNumFormat(__instance.AddCardChoose), medsSpriteText("card")));
							}
							else
							{
								stringBuilder2.Append(medsColorTextArray("", medsNumFormat(__instance.AddCard), medsSpriteText("card")));
							}
							if ((int)__instance.AddCardType > 0)
							{
								stringBuilder2.Append("<color=#5E3016>");
								stringBuilder2.Append(Texts.Instance.GetText(Enum.GetName(typeof(CardType), __instance.AddCardType), ""));
								stringBuilder2.Append("</color>");
							}
							arg = stringBuilder2.ToString();
							stringBuilder2.Clear();
						}
						string text5 = "";
						if (__instance.AddCardReducedCost == -1)
						{
							text5 = (__instance.AddCardVanish ? ((!__instance.AddCardCostTurn) ? string.Format(Texts.Instance.GetText("cardsAddCostVanish", ""), 0) : string.Format(Texts.Instance.GetText("cardsAddCostVanish", ""), 0)) : ((!__instance.AddCardCostTurn) ? string.Format(Texts.Instance.GetText("cardsAddCost", ""), 0) : string.Format(Texts.Instance.GetText("cardsAddCostTurn", ""), 0)));
						}
						else if (__instance.AddCardReducedCost > 0)
						{
							text5 = (__instance.AddCardVanish ? ((!__instance.AddCardCostTurn) ? string.Format(Texts.Instance.GetText("cardsAddCostReducedVanish", ""), __instance.AddCardReducedCost) : string.Format(Texts.Instance.GetText("cardsAddCostReducedVanishTurn", ""), __instance.AddCardReducedCost)) : ((!__instance.AddCardCostTurn) ? string.Format(Texts.Instance.GetText("cardsAddCostReduced", ""), __instance.AddCardReducedCost) : string.Format(Texts.Instance.GetText("cardsAddCostReducedTurn", ""), __instance.AddCardReducedCost)));
						}
						string text6 = "";
						if (__instance.AddCardId != "")
						{
							if ((int)__instance.AddCardPlace == 3)
							{
								text6 = (((int)__instance.TargetSide == 3 || ((int)__instance.TargetSide == 0 && (int)__instance.CardClass != 5)) ? "cardsIDShuffleDeck" : "cardsIDShuffleTargetDeck");
							}
							else if ((int)__instance.AddCardPlace == 5)
							{
								text6 = "cardsIDPlaceHand";
							}
							else if ((int)__instance.AddCardPlace == 1)
							{
								text6 = (((int)__instance.TargetSide != 3) ? "cardsIDPlaceTargetTopDeck" : "cardsIDPlaceTopDeck");
							}
							else if ((int)__instance.AddCardPlace == 0)
							{
								text6 = (((int)__instance.TargetSide == 3 || ((int)__instance.TargetSide == 0 && (int)__instance.CardClass != 5)) ? "cardsIDPlaceDiscard" : "cardsIDPlaceTargetDiscard");
							}
						}
						else if ((int)__instance.AddCardFrom == 2)
						{
							if ((int)__instance.AddCardPlace == 3)
							{
								text6 = ((__instance.AddCardChoose != 0) ? "cardsDiscoverNumberToDeck" : "cardsDiscoverToDeck");
							}
							else if ((int)__instance.AddCardPlace == 5)
							{
								text6 = ((__instance.AddCardChoose != 0) ? "cardsDiscoverNumberToHand" : "cardsDiscoverToHand");
							}
							else if ((int)__instance.AddCardPlace == 1 && __instance.AddCardChoose != 0)
							{
								text6 = "cardsDiscoverNumberToTopDeck";
							}
							else if ((int)__instance.AddCardPlace == 6)
							{
								CardData cardData2 = Globals.Instance.GetCardData(__instance.AddCardId, false);
								if ((Object)(object)cardData2 != (Object)null)
								{
									stringBuilder2.Clear();
									stringBuilder2.Append(medsColorFromCardDataRarity(cardData2));
									stringBuilder2.Append(cardData2.CardName);
									stringBuilder2.Append("</color>");
									text6 = string.Format(Texts.Instance.GetText("cardsCast", ""), stringBuilder2.ToString());
									stringBuilder2.Clear();
								}
							}
						}
						else if ((int)__instance.AddCardFrom == 0)
						{
							if ((int)__instance.AddCardPlace == 5)
							{
								text6 = ((__instance.AddCardChoose > 0) ? "cardsRevealNumberToHand" : ((__instance.AddCard <= 1) ? "cardsRevealItToHand" : "cardsRevealThemToHand"));
							}
							else if ((int)__instance.AddCardPlace == 1)
							{
								text6 = ((__instance.AddCardChoose > 0) ? "cardsRevealNumberToTopDeck" : ((__instance.AddCard <= 1) ? "cardsRevealItToTopDeck" : "cardsRevealThemToTopDeck"));
							}
						}
						else if ((int)__instance.AddCardFrom == 1)
						{
							if ((int)__instance.AddCardPlace == 1)
							{
								text6 = "cardsPickToTop";
							}
							else if ((int)__instance.AddCardPlace == 5)
							{
								text6 = "cardsPickToHand";
							}
						}
						else if ((int)__instance.AddCardFrom == 3)
						{
							if ((int)__instance.TargetSide == 1)
							{
								if ((int)__instance.AddCardPlace == 1)
								{
									text6 = "cardsDuplicateToTargetTopDeck";
								}
								else if ((int)__instance.AddCardPlace == 3)
								{
									text6 = "cardsDuplicateToTargetRandomDeck";
								}
							}
							else if ((int)__instance.AddCardPlace == 5)
							{
								text6 = "cardsDuplicateToHand";
							}
						}
						else if ((int)__instance.AddCardFrom == 4)
						{
							if ((int)__instance.AddCardPlace == 1)
							{
								text6 = "cardsFromVanishToTop";
							}
							else if ((int)__instance.AddCardPlace == 5)
							{
								text6 = "cardsFromVanishToHand";
							}
						}
						stringBuilder.Append(string.Format(Texts.Instance.GetText(text6, ""), arg, medsColorTextArray("", medsNumFormat(__instance.AddCard))));
						if (text5 != "")
						{
							stringBuilder.Append(" ");
							stringBuilder.Append(value6);
							stringBuilder.Append(text5);
							stringBuilder.Append(value7);
						}
						stringBuilder.Append("\n");
					}
					if (__instance.DiscardCard != 0)
					{
						if ((int)__instance.DiscardCardType > 0)
						{
							stringBuilder2.Append("<color=#5E3016>");
							stringBuilder2.Append(Texts.Instance.GetText(Enum.GetName(typeof(CardType), __instance.DiscardCardType), ""));
							stringBuilder2.Append("</color>");
						}
						if ((int)__instance.DiscardCardPlace == 0)
						{
							if (!__instance.DiscardCardAutomatic)
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDiscard", ""), medsColorTextArray("", medsNumFormat(__instance.DiscardCard), medsSpriteText("card"))));
								stringBuilder.Append(stringBuilder2);
								stringBuilder.Append("\n");
							}
							else
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDiscard", ""), medsColorTextArray("", medsNumFormat(__instance.DiscardCard), medsSpriteText("cardrandom"))));
								stringBuilder.Append(stringBuilder2);
								stringBuilder.Append("\n");
							}
						}
						else if ((int)__instance.DiscardCardPlace == 1)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPlaceToTop", ""), medsColorTextArray("", medsNumFormat(__instance.DiscardCard), medsSpriteText("card"), stringBuilder2.ToString().Trim())));
							stringBuilder.Append("\n");
						}
						else if ((int)__instance.DiscardCardPlace == 4)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsVanish", ""), medsColorTextArray("", medsNumFormat(__instance.DiscardCard), medsSpriteText("card"), stringBuilder2.ToString().Trim())));
							stringBuilder.Append("\n");
						}
						stringBuilder2.Clear();
					}
					if (__instance.LookCards != 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsLook", ""), medsColorTextArray("", medsNumFormat(__instance.LookCards), medsSpriteText("card"))));
						stringBuilder.Append("\n");
						if (__instance.LookCardsDiscardUpTo == -1)
						{
							stringBuilder.Append(Texts.Instance.GetText("cardsDiscardAny", ""));
							stringBuilder.Append("\n");
						}
						else if (__instance.LookCardsDiscardUpTo > 0)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDiscardUpTo", ""), medsColorTextArray("", medsNumFormat(__instance.LookCardsDiscardUpTo))));
							stringBuilder.Append("\n");
						}
						else if (__instance.LookCardsVanishUpTo > 0)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsVanishUpTo", ""), medsColorTextArray("", medsNumFormat(__instance.LookCardsVanishUpTo))));
							stringBuilder.Append("\n");
						}
					}
					num = 0;
					if ((Object)(object)__instance.SummonUnit != (Object)null && __instance.SummonUnitNum > 0)
					{
						stringBuilder2.Append("\n<color=#5E3016>");
						if (__instance.SummonUnitNum > 1)
						{
							stringBuilder2.Append(__instance.SummonUnitNum);
							stringBuilder2.Append(" ");
						}
						if ((Object)(object)__instance.SummonUnit != (Object)null && (Object)(object)Globals.Instance.GetNPC(__instance.SummonUnit.Id) != (Object)null)
						{
							stringBuilder2.Append(Globals.Instance.GetNPC(__instance.SummonUnit.Id).NPCName);
						}
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsSummon", ""), stringBuilder2.ToString()));
						stringBuilder.Append("</color>\n");
						stringBuilder2.Clear();
					}
					if (__instance.DispelAuras > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPurge", ""), medsColorTextArray("aura", __instance.DispelAuras.ToString())));
						stringBuilder.Append("\n");
					}
					else if (__instance.DispelAuras == -1)
					{
						stringBuilder.Append(Texts.Instance.GetText("cardsPurgeAll", ""));
						stringBuilder.Append("\n");
					}
					num = 0;
					if ((int)__instance.SpecialValueGlobal == 0 && (int)__instance.SpecialValue1 == 0 && (int)__instance.SpecialValue2 == 0)
					{
						StringBuilder stringBuilder4 = new StringBuilder();
						StringBuilder stringBuilder5 = new StringBuilder();
						if ((Object)(object)__instance.HealAuraCurseName != (Object)null)
						{
							if (__instance.HealAuraCurseName.IsAura)
							{
								stringBuilder4.Append(medsSpriteText(__instance.HealAuraCurseName.ACName));
							}
							else
							{
								stringBuilder5.Append(medsSpriteText(__instance.HealAuraCurseName.ACName));
							}
						}
						if ((Object)(object)__instance.HealAuraCurseName2 != (Object)null)
						{
							if (__instance.HealAuraCurseName2.IsAura)
							{
								stringBuilder4.Append(medsSpriteText(__instance.HealAuraCurseName2.ACName));
							}
							else
							{
								stringBuilder5.Append(medsSpriteText(__instance.HealAuraCurseName2.ACName));
							}
						}
						if ((Object)(object)__instance.HealAuraCurseName3 != (Object)null)
						{
							if (__instance.HealAuraCurseName3.IsAura)
							{
								stringBuilder4.Append(medsSpriteText(__instance.HealAuraCurseName3.ACName));
							}
							else
							{
								stringBuilder5.Append(medsSpriteText(__instance.HealAuraCurseName3.ACName));
							}
						}
						if ((Object)(object)__instance.HealAuraCurseName4 != (Object)null)
						{
							if (__instance.HealAuraCurseName4.IsAura)
							{
								stringBuilder4.Append(medsSpriteText(__instance.HealAuraCurseName4.ACName));
							}
							else
							{
								stringBuilder5.Append(medsSpriteText(__instance.HealAuraCurseName4.ACName));
							}
						}
						if (stringBuilder4.Length > 0)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPurge", ""), stringBuilder4.ToString()));
							stringBuilder.Append("\n");
						}
						if (stringBuilder5.Length > 0)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDispel", ""), stringBuilder5.ToString()));
							stringBuilder.Append("\n");
						}
						if (__instance.HealCurses > 0)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDispel", ""), medsColorTextArray("curse", __instance.HealCurses.ToString())));
							stringBuilder.Append("\n");
						}
						if (__instance.HealCurses == -1)
						{
							stringBuilder.Append(Texts.Instance.GetText("cardsDispelAll", ""));
							stringBuilder.Append("\n");
						}
						if ((Object)(object)__instance.HealAuraCurseSelf != (Object)null)
						{
							if (__instance.HealAuraCurseSelf.IsAura)
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPurgeYour", ""), medsSpriteText(__instance.HealAuraCurseSelf.ACName)));
							}
							else
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDispelYour", ""), medsSpriteText(__instance.HealAuraCurseSelf.ACName)));
							}
							stringBuilder.Append("\n");
						}
					}
					else
					{
						if (__instance.HealCurses > 0)
						{
							if ((int)__instance.TargetSide == 0)
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPurge", ""), __instance.HealCurses));
							}
							else
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDispel", ""), __instance.HealCurses));
							}
							stringBuilder.Append("\n");
						}
						if ((Object)(object)__instance.HealAuraCurseName4 != (Object)null && (Object)(object)__instance.HealAuraCurseName3 == (Object)null)
						{
							StringBuilder stringBuilder6 = new StringBuilder();
							StringBuilder stringBuilder7 = new StringBuilder();
							if (__instance.HealAuraCurseName4.IsAura)
							{
								stringBuilder6.Append(medsSpriteText(__instance.HealAuraCurseName4.ACName));
							}
							else
							{
								stringBuilder7.Append(medsSpriteText(__instance.HealAuraCurseName4.ACName));
							}
							if (stringBuilder6.Length > 0)
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPurge", ""), stringBuilder6.ToString()));
								stringBuilder.Append("\n");
							}
							if (stringBuilder7.Length > 0)
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDispel", ""), stringBuilder7.ToString()));
								stringBuilder.Append("\n");
							}
						}
					}
					if (__instance.TransferCurses > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsTransferCurse", ""), __instance.TransferCurses.ToString()));
						stringBuilder.Append("\n");
					}
					if (__instance.StealAuras > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsStealAuras", ""), __instance.StealAuras.ToString()));
						stringBuilder.Append("\n");
					}
					if (__instance.IncreaseAuras > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsIncreaseAura", ""), __instance.IncreaseAuras.ToString()));
						stringBuilder.Append("\n");
					}
					if (__instance.IncreaseCurses > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsIncreaseCurse", ""), __instance.IncreaseCurses.ToString()));
						stringBuilder.Append("\n");
					}
					if (__instance.ReduceAuras > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsReduceAura", ""), __instance.ReduceAuras.ToString()));
						stringBuilder.Append("\n");
					}
					if (__instance.ReduceCurses > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsReduceCurse", ""), __instance.ReduceCurses.ToString()));
						stringBuilder.Append("\n");
					}
					int num3 = 0;
					if (__instance.Damage > 0 && !__instance.DamageSpecialValue1 && !__instance.DamageSpecialValue2 && !__instance.DamageSpecialValueGlobal)
					{
						int num4 = num3 + 1;
						num3 = num4;
						stringBuilder2.Append(medsColorTextArray("damage", medsNumFormat(__instance.DamagePreCalculated), medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType))));
						if (__instance.Damage2 > 0 && __instance.DamageType == __instance.DamageType2 && (__instance.Damage2SpecialValue1 || __instance.Damage2SpecialValue2 || __instance.Damage2SpecialValueGlobal))
						{
							stringBuilder2.Append("<space=-.3>");
							stringBuilder2.Append("+");
							stringBuilder2.Append(medsColorTextArray("damage", "X", medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType))));
						}
					}
					if (__instance.Damage2 > 0 && !__instance.Damage2SpecialValue1 && !__instance.Damage2SpecialValue2 && !__instance.Damage2SpecialValueGlobal)
					{
						int num4 = num3 + 1;
						num3 = num4;
						stringBuilder2.Append(medsColorTextArray("damage", medsNumFormat(__instance.DamagePreCalculated2), medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType2))));
					}
					if (num3 > 0)
					{
						if (flag4 && num3 > 1)
						{
							stringBuilder2.Insert(0, value5);
							stringBuilder2.Insert(0, "\n");
						}
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDealDamage", ""), stringBuilder2.ToString()));
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					int num5 = 0;
					if (__instance.DamageSelf > 0)
					{
						int num4 = num5 + 1;
						num5 = num4;
						if (__instance.DamageSpecialValueGlobal || __instance.DamageSpecialValue1 || __instance.DamageSpecialValue2)
						{
							stringBuilder2.Append(medsColorTextArray("damage", "X", medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType))));
						}
						else
						{
							stringBuilder2.Append(medsColorTextArray("damage", medsNumFormat(__instance.DamageSelfPreCalculated), medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType))));
						}
					}
					if (__instance.DamageSelf2 > 0)
					{
						int num4 = num5 + 1;
						num5 = num4;
						if (__instance.Damage2SpecialValueGlobal || __instance.Damage2SpecialValue1 || __instance.Damage2SpecialValue2)
						{
							stringBuilder2.Append(medsColorTextArray("damage", "X", medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType2))));
						}
						else
						{
							stringBuilder2.Append(medsColorTextArray("damage", medsNumFormat(__instance.DamageSelfPreCalculated2), medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType2))));
						}
					}
					if (num5 > 0)
					{
						if (num5 > 2)
						{
							stringBuilder2.Insert(0, value5);
							stringBuilder2.Insert(0, "\n");
						}
						if ((int)__instance.TargetSide == 3)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsSuffer", ""), stringBuilder2.ToString()));
							stringBuilder.Append("\n");
						}
						else
						{
							stringBuilder3.Append(string.Format(Texts.Instance.GetText("cardsYouSuffer", ""), stringBuilder2.ToString()));
							stringBuilder3.Append("\n");
						}
						stringBuilder2.Clear();
					}
					if (stringBuilder3.Length > 0)
					{
						stringBuilder.Append(stringBuilder3.ToString());
						stringBuilder3.Clear();
					}
					if ((double)__instance.HealSelfPerDamageDonePercent > 0.0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsHealSelfPerDamage", ""), __instance.HealSelfPerDamageDonePercent.ToString()));
						stringBuilder.Append("\n");
					}
					if (__instance.SelfHealthLoss != 0 && !__instance.SelfHealthLossSpecialGlobal)
					{
						if (__instance.SelfHealthLossSpecialValue1)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsLoseHp", ""), medsColorTextArray("damage", "X HP")));
						}
						else
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsLoseHp", ""), medsColorTextArray("damage", medsNumFormat(__instance.SelfHealthLoss), "HP")));
						}
						stringBuilder.Append("\n");
					}
					if (((int)__instance.TargetSide == 1 || (int)__instance.TargetSide == 4) && (int)__instance.SpecialValueGlobal == 1 && (Object)(object)__instance.SpecialAuraCurseNameGlobal != (Object)null && (double)__instance.SpecialValueModifierGlobal > 0.0)
					{
						flag = true;
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsShareYour", ""), medsSpriteText(__instance.SpecialAuraCurseNameGlobal.ACName)));
						stringBuilder.Append("\n");
					}
					if (!__instance.Damage2SpecialValue1 && !flag && ((int)__instance.SpecialValueGlobal != 0 || (int)__instance.SpecialValue1 != 0 || (int)__instance.SpecialValue2 > 0) && !__instance.DamageSpecialValueGlobal && !__instance.DamageSpecialValue1 && !__instance.DamageSpecialValue2)
					{
						if ((int)__instance.TargetSide == 3 && ((int)__instance.SpecialValueGlobal == 2 || (int)__instance.SpecialValueGlobal == 1))
						{
							if ((Object)(object)__instance.SpecialAuraCurseNameGlobal != (Object)null)
							{
								text = medsSpriteText(__instance.SpecialAuraCurseNameGlobal.ACName);
							}
							if (__instance.AuraChargesSpecialValueGlobal)
							{
								if ((Object)(object)__instance.Aura != (Object)null)
								{
									text2 = medsSpriteText(__instance.Aura.ACName);
								}
								if ((Object)(object)__instance.Aura2 != (Object)null && __instance.AuraCharges2SpecialValueGlobal)
								{
									text3 = medsSpriteText(__instance.Aura2.ACName);
								}
							}
							else if (__instance.CurseChargesSpecialValueGlobal)
							{
								if ((Object)(object)__instance.Curse != (Object)null)
								{
									text2 = medsSpriteText(__instance.Curse.ACName);
								}
								if ((Object)(object)__instance.Curse2 != (Object)null && __instance.CurseCharges2SpecialValueGlobal)
								{
									text3 = medsSpriteText(__instance.Curse2.ACName);
								}
							}
						}
						else if ((int)__instance.SpecialValue1 == 2)
						{
							if ((Object)(object)__instance.SpecialAuraCurseName1 != (Object)null)
							{
								text = medsSpriteText(__instance.SpecialAuraCurseName1.ACName);
							}
							if (__instance.AuraChargesSpecialValue1)
							{
								if ((Object)(object)__instance.Aura != (Object)null)
								{
									text2 = medsSpriteText(__instance.Aura.ACName);
								}
								if ((Object)(object)__instance.Aura2 != (Object)null && __instance.AuraCharges2SpecialValue1)
								{
									text3 = medsSpriteText(__instance.Aura2.ACName);
								}
							}
							else if (__instance.CurseChargesSpecialValue1)
							{
								if ((Object)(object)__instance.Curse != (Object)null)
								{
									text2 = medsSpriteText(__instance.Curse.ACName);
								}
								if ((Object)(object)__instance.Curse2 != (Object)null && __instance.CurseCharges2SpecialValue1)
								{
									text3 = medsSpriteText(__instance.Curse2.ACName);
								}
							}
						}
						if (text != "" && text2 != "")
						{
							flag2 = true;
							if (text == text2)
							{
								if ((int)__instance.SpecialValueGlobal == 2)
								{
									if ((double)__instance.SpecialValueModifierGlobal == 100.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDoubleTarget", ""), text));
										stringBuilder.Append("\n");
									}
									else if ((double)__instance.SpecialValueModifierGlobal == 200.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsTripleTarget", ""), text));
										stringBuilder.Append("\n");
									}
									else if ((double)__instance.SpecialValueModifierGlobal < 100.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsLosePercentTarget", ""), (float)(100.0 - (double)__instance.SpecialValueModifierGlobal), text));
										stringBuilder.Append("\n");
									}
								}
								else if ((int)__instance.SpecialValueGlobal == 1)
								{
									if ((double)__instance.SpecialValueModifierGlobal == 100.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDoubleYour", ""), text));
										stringBuilder.Append("\n");
									}
									else if ((double)__instance.SpecialValueModifierGlobal == 200.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsTripleYour", ""), text));
										stringBuilder.Append("\n");
									}
									else if ((double)__instance.SpecialValueModifierGlobal < 100.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsLosePercentYour", ""), (float)(100.0 - (double)__instance.SpecialValueModifierGlobal), text));
										stringBuilder.Append("\n");
									}
								}
								else if ((int)__instance.SpecialValue1 == 2)
								{
									if ((double)__instance.SpecialValueModifier1 == 100.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDoubleTarget", ""), text));
										stringBuilder.Append("\n");
									}
									else if ((double)__instance.SpecialValueModifier1 == 200.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsTripleTarget", ""), text));
										stringBuilder.Append("\n");
									}
									else if ((double)__instance.SpecialValueModifier1 < 100.0 && (Object)(object)__instance.HealAuraCurseName != (Object)null)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsLosePercentTarget", ""), (float)(100.0 - (double)__instance.SpecialValueModifier1), text));
										stringBuilder.Append("\n");
									}
									else
									{
										flag2 = false;
									}
								}
								else if ((int)__instance.SpecialValue1 == 1)
								{
									if ((double)__instance.SpecialValueModifier1 == 100.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDoubleYour", ""), text));
										stringBuilder.Append("\n");
									}
									else if ((double)__instance.SpecialValueModifier1 == 200.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsTripleYour", ""), text));
										stringBuilder.Append("\n");
									}
									else if ((double)__instance.SpecialValueModifier1 < 100.0)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsLosePercentYour", ""), (float)(100.0 - (double)__instance.SpecialValueModifier1), text));
										stringBuilder.Append("\n");
									}
								}
							}
							else
							{
								stringBuilder2.Append(text2);
								if ((double)__instance.SpecialValueModifier1 > 0.0)
								{
									num2 = __instance.SpecialValueModifier1 / 100f;
								}
								if ((double)num2 > 0.0 && (double)num2 != 1.0)
								{
									text4 = "x " + num2;
								}
								if (text4 != "")
								{
									stringBuilder2.Append(" <c>");
									stringBuilder2.Append(text4);
									stringBuilder2.Append("</c>");
								}
								if (text3 != "")
								{
									stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsTransformIntoAnd", ""), text, stringBuilder2.ToString(), text3));
								}
								else
								{
									stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsTransformInto", ""), text, stringBuilder2.ToString()));
								}
								stringBuilder.Append("\n");
								stringBuilder2.Clear();
								num2 = 0f;
								text4 = "";
							}
						}
					}
					if (__instance.EnergyRechargeSpecialValueGlobal)
					{
						stringBuilder2.Append(medsColorTextArray("aura", "X", medsSpriteText("energy")));
					}
					int num6 = 0;
					if (__instance.Damage > 0 && (__instance.DamageSpecialValue1 || __instance.DamageSpecialValueGlobal))
					{
						stringBuilder2.Append(medsColorTextArray("damage", "X", medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType))));
						int num4 = num6 + 1;
						num6 = num4;
					}
					if (__instance.Damage2 > 0 && (__instance.DamageSpecialValue2 || __instance.DamageSpecialValueGlobal))
					{
						stringBuilder2.Append(medsColorTextArray("damage", "X", medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType2))));
						int num4 = num6 + 1;
						num6 = num4;
					}
					else if (__instance.Damage2 > 0 && __instance.Damage2SpecialValueGlobal && __instance.DamageType != __instance.DamageType2)
					{
						stringBuilder2.Append(medsColorTextArray("damage", "X", medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType2))));
						int num4 = num6 + 1;
						num6 = num4;
					}
					if (__instance.Damage2 > 0 && __instance.Damage2SpecialValue1 && (__instance.DamageSpecialValue1 || __instance.DamageSpecialValue2 || __instance.DamageSpecialValueGlobal))
					{
						stringBuilder2.Append(medsColorTextArray("damage", "X", medsSpriteText(Enum.GetName(typeof(DamageType), __instance.DamageType2))));
						int num4 = num6 + 1;
						num6 = num4;
					}
					if (num6 > 0)
					{
						if (flag4 && num6 > 1)
						{
							stringBuilder2.Insert(0, value5);
							stringBuilder2.Insert(0, "\n");
						}
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDealDamage", ""), stringBuilder2.ToString()));
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					AuraCurseData val = null;
					if (!flag && !flag2)
					{
						int num7 = 0;
						if ((Object)(object)__instance.Aura != (Object)null && (__instance.AuraChargesSpecialValue1 || __instance.AuraChargesSpecialValueGlobal))
						{
							int num4 = num7 + 1;
							num7 = num4;
							stringBuilder2.Append(medsColorTextArray("aura", "X", medsSpriteText(__instance.Aura.ACName)));
							val = __instance.Aura;
						}
						if ((Object)(object)__instance.Aura2 != (Object)null && (__instance.AuraCharges2SpecialValue1 || __instance.AuraCharges2SpecialValueGlobal))
						{
							int num4 = num7 + 1;
							num7 = num4;
							if ((Object)(object)__instance.Aura != (Object)null && (Object)(object)__instance.Aura == (Object)(object)__instance.Aura2)
							{
								stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Aura.Id, __instance.AuraCharges, character)), medsSpriteText(__instance.Aura.ACName)));
								stringBuilder2.Append("+");
							}
							stringBuilder2.Append(medsColorTextArray("aura", "X", medsSpriteText(__instance.Aura2.ACName)));
							val = __instance.Aura2;
						}
						if ((Object)(object)__instance.Aura3 != (Object)null && (__instance.AuraCharges3SpecialValue1 || __instance.AuraCharges3SpecialValueGlobal))
						{
							int num4 = num7 + 1;
							num7 = num4;
							if ((Object)(object)__instance.Aura != (Object)null && (Object)(object)__instance.Aura == (Object)(object)__instance.Aura3)
							{
								stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Aura.Id, __instance.AuraCharges, character)), medsSpriteText(__instance.Aura.ACName)));
								stringBuilder2.Append("+");
							}
							if ((Object)(object)__instance.Aura2 != (Object)null && (Object)(object)__instance.Aura == (Object)(object)__instance.Aura3)
							{
								stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Aura2.Id, __instance.AuraCharges2, character)), medsSpriteText(__instance.Aura3.ACName)));
								stringBuilder2.Append("+");
							}
							stringBuilder2.Append(medsColorTextArray("aura", "X", medsSpriteText(__instance.Aura3.ACName)));
							val = __instance.Aura3;
						}
						if (num7 > 0)
						{
							if ((int)__instance.TargetSide == 3)
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsGain", ""), stringBuilder2.ToString()));
							}
							else
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsGrant", ""), stringBuilder2.ToString()));
							}
							stringBuilder.Append("\n");
							stringBuilder2.Clear();
						}
					}
					if (!flag && !flag2)
					{
						int num8 = 0;
						if ((Object)(object)__instance.Curse != (Object)null && (__instance.CurseChargesSpecialValue1 || __instance.CurseChargesSpecialValueGlobal))
						{
							int num4 = num8 + 1;
							num8 = num4;
							stringBuilder2.Append(medsColorTextArray("curse", "X", medsSpriteText(__instance.Curse.ACName)));
						}
						if ((Object)(object)__instance.Curse2 != (Object)null && (__instance.CurseCharges2SpecialValue1 || __instance.CurseCharges2SpecialValueGlobal))
						{
							int num4 = num8 + 1;
							num8 = num4;
							stringBuilder2.Append(medsColorTextArray("curse", "X", medsSpriteText(__instance.Curse2.ACName)));
						}
						if ((Object)(object)__instance.Curse3 != (Object)null && (__instance.CurseCharges3SpecialValue1 || __instance.CurseCharges3SpecialValueGlobal))
						{
							int num4 = num8 + 1;
							num8 = num4;
							stringBuilder2.Append(medsColorTextArray("curse", "X", medsSpriteText(__instance.Curse3.ACName)));
						}
						if (num8 > 0)
						{
							if ((int)__instance.TargetSide == 3)
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsSuffer", ""), stringBuilder2.ToString()));
							}
							else
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsApply", ""), stringBuilder2.ToString()));
							}
							stringBuilder.Append("\n");
							stringBuilder2.Clear();
						}
						int num9 = 0;
						if ((Object)(object)__instance.CurseSelf != (Object)null && (__instance.CurseChargesSpecialValue1 || __instance.CurseChargesSpecialValueGlobal))
						{
							int num4 = num9 + 1;
							num9 = num4;
							stringBuilder2.Append(medsColorTextArray("curse", "X", medsSpriteText(__instance.CurseSelf.ACName)));
						}
						if ((Object)(object)__instance.CurseSelf2 != (Object)null && (__instance.CurseCharges2SpecialValue1 || __instance.CurseCharges2SpecialValueGlobal))
						{
							int num4 = num9 + 1;
							num9 = num4;
							stringBuilder2.Append(medsColorTextArray("curse", "X", medsSpriteText(__instance.CurseSelf2.ACName)));
						}
						if ((Object)(object)__instance.CurseSelf3 != (Object)null && (__instance.CurseCharges3SpecialValue1 || __instance.CurseCharges3SpecialValueGlobal))
						{
							int num4 = num9 + 1;
							num9 = num4;
							stringBuilder2.Append(medsColorTextArray("curse", "X", medsSpriteText(__instance.CurseSelf3.ACName)));
						}
						if (num9 > 0)
						{
							if ((int)__instance.TargetSide == 3 || (Object)(object)__instance.CurseSelf != (Object)null || (Object)(object)__instance.CurseSelf2 != (Object)null || (Object)(object)__instance.CurseSelf3 != (Object)null)
							{
								if ((int)__instance.TargetSide == 3)
								{
									stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsSuffer", ""), stringBuilder2.ToString()));
									stringBuilder.Append("\n");
								}
								else if (!flag3)
								{
									stringBuilder3.Append(string.Format(Texts.Instance.GetText("cardsYouSuffer", ""), stringBuilder2.ToString()));
									stringBuilder3.Append("\n");
								}
								else
								{
									stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsYouSuffer", ""), stringBuilder2.ToString()));
									stringBuilder.Append("\n");
								}
							}
							else
							{
								stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsApply", ""), stringBuilder2.ToString()));
								stringBuilder.Append("\n");
							}
							stringBuilder2.Clear();
						}
					}
					int num10 = 0;
					if (__instance.Heal > 0 && (__instance.HealSpecialValue1 || __instance.HealSpecialValueGlobal))
					{
						stringBuilder2.Append(medsColorTextArray("heal", "X", medsSpriteText("heal")));
						num = num10 + 1;
					}
					if (stringBuilder2.Length > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsHeal", ""), stringBuilder2.ToString()));
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					int num11 = 0;
					if (__instance.HealSelf > 0 && (__instance.HealSelfSpecialValue1 || __instance.HealSelfSpecialValueGlobal))
					{
						stringBuilder2.Append(medsColorTextArray("heal", "X", medsSpriteText("heal")));
						num = num11 + 1;
					}
					if (stringBuilder2.Length > 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsHealSelf", ""), stringBuilder2.ToString()));
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					if (!flag && !flag2)
					{
						if ((double)__instance.SpecialValueModifierGlobal > 0.0)
						{
							num2 = __instance.SpecialValueModifierGlobal / 100f;
						}
						else if ((double)__instance.SpecialValueModifier1 > 0.0)
						{
							num2 = __instance.SpecialValueModifier1 / 100f;
						}
						if ((double)num2 > 0.0 && (double)num2 != 1.0)
						{
							text4 = "x" + num2;
						}
						if (text4 == "")
						{
							text4 = "<space=-.1>";
						}
						if ((int)__instance.SpecialValue1 == 1)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYour", ""), medsSpriteText(__instance.SpecialAuraCurseName1.ACName), text4));
						}
						else if ((int)__instance.SpecialValue1 == 2)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsTarget", ""), medsSpriteText(__instance.SpecialAuraCurseName1.ACName), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 1)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYour", ""), medsSpriteText(__instance.SpecialAuraCurseNameGlobal.ACName), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 2)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsTarget", ""), medsSpriteText(__instance.SpecialAuraCurseNameGlobal.ACName), text4));
						}
						if ((int)__instance.SpecialValueGlobal == 6)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourHp", ""), text4));
						}
						else if ((int)__instance.SpecialValue1 == 6)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourHp", ""), text4));
						}
						else if ((int)__instance.SpecialValue1 == 7)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsTargetHp", ""), text4));
						}
						if ((int)__instance.SpecialValueGlobal == 12)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourSpeed", ""), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 13)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsTargetSpeed", ""), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 14 || (int)__instance.SpecialValue1 == 14)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsDifferenceSpeed", ""), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 17)
						{
							if ((int)__instance.DiscardCardPlace == 4)
							{
								stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourVanishedCards", ""), text4));
							}
							else
							{
								stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourDiscardedCards", ""), text4));
							}
						}
						else if ((int)__instance.SpecialValueGlobal == 18)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourVanishedCards", ""), text4));
						}
						if ((int)__instance.SpecialValueGlobal == 3 || (int)__instance.SpecialValue1 == 3 || (int)__instance.SpecialValue2 == 3)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourHand", ""), medsSpriteText("card"), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 4 || (int)__instance.SpecialValue1 == 4 || (int)__instance.SpecialValue2 == 4)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourDeck", ""), medsSpriteText("card"), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 5 || (int)__instance.SpecialValue1 == 5 || (int)__instance.SpecialValue2 == 5)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourDiscard", ""), medsSpriteText("card"), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 8 || (int)__instance.SpecialValue1 == 8 || (int)__instance.SpecialValue2 == 8)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourVanish", ""), medsSpriteText("card"), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 9 || (int)__instance.SpecialValue1 == 9 || (int)__instance.SpecialValue2 == 9)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsTargetDeck", ""), medsSpriteText("card"), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 10 || (int)__instance.SpecialValue1 == 10 || (int)__instance.SpecialValue2 == 10)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsTargetDiscard", ""), medsSpriteText("card"), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 11 || (int)__instance.SpecialValue1 == 11 || (int)__instance.SpecialValue2 == 11)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsTargetVanish", ""), medsSpriteText("card"), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 15 || (int)__instance.SpecialValue1 == 15)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsYourMissingHealth", ""), text4));
						}
						else if ((int)__instance.SpecialValueGlobal == 16 || (int)__instance.SpecialValue1 == 16)
						{
							stringBuilder2.Append(string.Format(Texts.Instance.GetText("cardsXEqualsTargetMissingHealth", ""), text4));
						}
						if (stringBuilder2.Length > 0)
						{
							stringBuilder.Append(value8);
							stringBuilder.Append(stringBuilder2);
							stringBuilder.Append(value7);
							stringBuilder.Append("\n");
							stringBuilder2.Clear();
							if ((Object)(object)__instance.HealAuraCurseName != (Object)null)
							{
								if ((int)__instance.TargetSide == 3)
								{
									if (__instance.HealAuraCurseName.IsAura)
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPurgeYour", ""), medsSpriteText(__instance.HealAuraCurseName.ACName)));
									}
									else
									{
										stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDispelYour", ""), medsSpriteText(__instance.HealAuraCurseName.ACName)));
									}
								}
								else if (__instance.HealAuraCurseName.IsAura)
								{
									stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPurge", ""), medsSpriteText(__instance.HealAuraCurseName.ACName)));
								}
								else
								{
									stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDispel", ""), medsSpriteText(__instance.HealAuraCurseName.ACName)));
								}
								stringBuilder.Append("\n");
							}
							if ((Object)(object)__instance.HealAuraCurseSelf != (Object)null)
							{
								if (__instance.HealAuraCurseSelf.IsAura)
								{
									stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsPurgeYour", ""), medsSpriteText(__instance.HealAuraCurseSelf.ACName)));
								}
								else
								{
									stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsDispelYour", ""), medsSpriteText(__instance.HealAuraCurseSelf.ACName)));
								}
								stringBuilder.Append("\n");
							}
						}
						num2 = 0f;
					}
					if (__instance.SelfHealthLoss > 0 && __instance.SelfHealthLossSpecialGlobal)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsYouLose", ""), medsColorTextArray("damage", "X", "HP")));
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					int num12 = 0;
					if ((Object)(object)__instance.CurseSelf != (Object)null && __instance.CurseCharges > 0)
					{
						int num4 = num12 + 1;
						num12 = num4;
						stringBuilder2.Append(medsColorTextArray("curse", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.CurseSelf.Id, __instance.CurseCharges, character)), medsSpriteText(__instance.CurseSelf.ACName)));
					}
					if ((Object)(object)__instance.CurseSelf2 != (Object)null && __instance.CurseCharges2 > 0)
					{
						int num4 = num12 + 1;
						num12 = num4;
						stringBuilder2.Append(medsColorTextArray("curse", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.CurseSelf2.Id, __instance.CurseCharges2, character)), medsSpriteText(__instance.CurseSelf2.ACName)));
					}
					if ((Object)(object)__instance.CurseSelf3 != (Object)null && __instance.CurseCharges3 > 0)
					{
						int num4 = num12 + 1;
						num12 = num4;
						stringBuilder2.Append(medsColorTextArray("curse", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.CurseSelf3.Id, __instance.CurseCharges3, character)), medsSpriteText(__instance.CurseSelf3.ACName)));
					}
					if (num12 > 0)
					{
						if (num12 > 2)
						{
							stringBuilder2.Insert(0, value5);
							stringBuilder2.Insert(0, "\n");
						}
						if ((int)__instance.TargetSide == 3)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsSuffer", ""), stringBuilder2.ToString()));
							stringBuilder.Append("\n");
						}
						else
						{
							stringBuilder3.Append(string.Format(Texts.Instance.GetText("cardsYouSuffer", ""), stringBuilder2.ToString()));
							stringBuilder3.Append("\n");
						}
						stringBuilder2.Clear();
					}
					int num13 = 0;
					if (__instance.EnergyRecharge < 0)
					{
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsLoseHp", ""), stringBuilder2.Append(medsColorTextArray("system", medsNumFormat(Mathf.Abs(__instance.EnergyRecharge)), medsSpriteText("energy")))));
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					if (__instance.EnergyRecharge > 0)
					{
						int num4 = num13 + 1;
						num13 = num4;
						stringBuilder2.Append(medsColorTextArray("system", medsNumFormat(__instance.EnergyRecharge), medsSpriteText("energy")));
					}
					if ((Object)(object)__instance.Aura != (Object)null && __instance.AuraCharges > 0 && (Object)(object)__instance.Aura != (Object)(object)val)
					{
						int num4 = num13 + 1;
						num13 = num4;
						stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Aura.Id, __instance.AuraCharges, character)), medsSpriteText(__instance.Aura.ACName)));
					}
					if ((Object)(object)__instance.Aura2 != (Object)null && __instance.AuraCharges2 > 0 && (Object)(object)__instance.Aura2 != (Object)(object)val)
					{
						int num4 = num13 + 1;
						num13 = num4;
						stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Aura2.Id, __instance.AuraCharges2, character)), medsSpriteText(__instance.Aura2.ACName)));
					}
					if ((Object)(object)__instance.Aura3 != (Object)null && __instance.AuraCharges3 > 0 && (Object)(object)__instance.Aura3 != (Object)(object)val)
					{
						int num4 = num13 + 1;
						num13 = num4;
						stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Aura3.Id, __instance.AuraCharges3, character)), medsSpriteText(__instance.Aura3.ACName)));
					}
					if (num13 > 0)
					{
						if (num13 > 2)
						{
							stringBuilder2.Insert(0, value5);
							stringBuilder2.Insert(0, "\n");
						}
						if ((int)__instance.TargetSide == 3)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsGain", ""), stringBuilder2.ToString()));
						}
						else
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsGrant", ""), stringBuilder2.ToString()));
						}
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					int num14 = 0;
					if ((Object)(object)__instance.AuraSelf != (Object)null && __instance.AuraCharges > 0)
					{
						int num4 = num14 + 1;
						num14 = num4;
						stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.AuraSelf.Id, __instance.AuraCharges, character)), medsSpriteText(__instance.AuraSelf.ACName)));
					}
					if ((Object)(object)__instance.AuraSelf2 != (Object)null && __instance.AuraCharges2 > 0)
					{
						int num4 = num14 + 1;
						num14 = num4;
						stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.AuraSelf2.Id, __instance.AuraCharges2, character)), medsSpriteText(__instance.AuraSelf2.ACName)));
					}
					if ((Object)(object)__instance.AuraSelf3 != (Object)null && __instance.AuraCharges3 > 0)
					{
						int num4 = num14 + 1;
						num14 = num4;
						stringBuilder2.Append(medsColorTextArray("aura", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.AuraSelf3.Id, __instance.AuraCharges3, character)), medsSpriteText(__instance.AuraSelf3.ACName)));
					}
					if (!flag)
					{
						if ((Object)(object)__instance.AuraSelf != (Object)null && (__instance.AuraChargesSpecialValue1 || __instance.AuraChargesSpecialValueGlobal))
						{
							int num4 = num14 + 1;
							num14 = num4;
							stringBuilder2.Append(medsColorTextArray("aura", "X", medsSpriteText(__instance.AuraSelf.ACName)));
						}
						if ((Object)(object)__instance.AuraSelf2 != (Object)null && (__instance.AuraCharges2SpecialValue1 || __instance.AuraCharges2SpecialValueGlobal))
						{
							int num4 = num14 + 1;
							num14 = num4;
							stringBuilder2.Append(medsColorTextArray("aura", "X", medsSpriteText(__instance.AuraSelf2.ACName)));
						}
						if ((Object)(object)__instance.AuraSelf3 != (Object)null && (__instance.AuraCharges3SpecialValue1 || __instance.AuraCharges3SpecialValueGlobal))
						{
							int num4 = num14 + 1;
							num14 = num4;
							stringBuilder2.Append(medsColorTextArray("aura", "X", medsSpriteText(__instance.AuraSelf3.ACName)));
						}
					}
					if (num14 > 0)
					{
						if (num14 > 2)
						{
							stringBuilder2.Insert(0, value5);
							stringBuilder2.Insert(0, "\n");
						}
						if ((int)__instance.TargetSide == 3)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsGain", ""), stringBuilder2.ToString()));
							stringBuilder.Append("\n");
						}
						else
						{
							stringBuilder3.Append(string.Format(Texts.Instance.GetText("cardsYouGain", ""), stringBuilder2.ToString()));
							stringBuilder3.Append("\n");
						}
						stringBuilder2.Clear();
					}
					int num15 = 0;
					if (__instance.CurseCharges > 0 && (Object)(object)__instance.Curse != (Object)null)
					{
						int num4 = num15 + 1;
						num15 = num4;
						stringBuilder2.Append(medsColorTextArray("curse", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Curse.Id, __instance.CurseCharges, character)), medsSpriteText(__instance.Curse.ACName)));
					}
					if (__instance.CurseCharges2 > 0 && (Object)(object)__instance.Curse2 != (Object)null)
					{
						int num4 = num15 + 1;
						num15 = num4;
						stringBuilder2.Append(medsColorTextArray("curse", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Curse2.Id, __instance.CurseCharges2, character)), medsSpriteText(__instance.Curse2.ACName)));
					}
					if (__instance.CurseCharges3 > 0 && (Object)(object)__instance.Curse3 != (Object)null)
					{
						int num4 = num15 + 1;
						num15 = num4;
						stringBuilder2.Append(medsColorTextArray("curse", medsNumFormat(medsGetFinalAuraCharges(__instance.CardClass, __instance.Curse3.Id, __instance.CurseCharges3, character)), medsSpriteText(__instance.Curse3.ACName)));
					}
					if (num15 > 0)
					{
						if (num15 > 2)
						{
							stringBuilder2.Insert(0, value5);
							stringBuilder2.Insert(0, "\n");
						}
						if ((int)__instance.TargetSide == 3)
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsSuffer", ""), stringBuilder2.ToString()));
						}
						else
						{
							stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsApply", ""), stringBuilder2.ToString()));
						}
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					if (__instance.Heal > 0 && !__instance.HealSpecialValue1 && !__instance.HealSpecialValueGlobal)
					{
						stringBuilder2.Append(medsColorTextArray("heal", medsNumFormat(value2), medsSpriteText("heal")));
						stringBuilder.Append(string.Format(Texts.Instance.GetText("cardsHeal", ""), stringBuilder2.ToString()));
						stringBuilder.Append("\n");
						stringBuilder2.Clear();
					}
					if (__instance.HealSelf > 0 && !__instance.HealSelfSpecialValue1 && !__instance.HealSelfSpecialValueGlobal)
					{
						stringBuilder2.Append(medsColorTextArray("heal", medsNumFormat(value

BepInEx/plugins/UniverseLib.Mono.dll

Decompiled 7 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using HarmonyLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UniverseLib.Config;
using UniverseLib.Input;
using UniverseLib.Runtime;
using UniverseLib.Runtime.Mono;
using UniverseLib.UI;
using UniverseLib.UI.Models;
using UniverseLib.UI.ObjectPool;
using UniverseLib.UI.Panels;
using UniverseLib.UI.Widgets;
using UniverseLib.UI.Widgets.ScrollView;
using UniverseLib.Utility;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UniverseLib")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Sinai")]
[assembly: AssemblyProduct("UniverseLib")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b21dbde3-5d6f-4726-93ab-cc3cc68bae7d")]
[assembly: AssemblyFileVersion("1.5.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.1.0")]
[module: UnverifiableCode]
public static class MonoExtensions
{
	private static PropertyInfo p_childControlHeight = AccessTools.Property(typeof(HorizontalOrVerticalLayoutGroup), "childControlHeight");

	private static PropertyInfo p_childControlWidth = AccessTools.Property(typeof(HorizontalOrVerticalLayoutGroup), "childControlWidth");

	public static void AddListener(this UnityEvent _event, Action listener)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		_event.AddListener(new UnityAction(listener.Invoke));
	}

	public static void AddListener<T>(this UnityEvent<T> _event, Action<T> listener)
	{
		_event.AddListener((UnityAction<T>)listener.Invoke);
	}

	public static void RemoveListener(this UnityEvent _event, Action listener)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		_event.RemoveListener(new UnityAction(listener.Invoke));
	}

	public static void RemoveListener<T>(this UnityEvent<T> _event, Action<T> listener)
	{
		_event.RemoveListener((UnityAction<T>)listener.Invoke);
	}

	public static void Clear(this StringBuilder sb)
	{
		sb.Remove(0, sb.Length);
	}

	public static void SetChildControlHeight(this HorizontalOrVerticalLayoutGroup group, bool value)
	{
		p_childControlHeight?.SetValue(group, value, null);
	}

	public static void SetChildControlWidth(this HorizontalOrVerticalLayoutGroup group, bool value)
	{
		p_childControlWidth?.SetValue(group, value, null);
	}
}
namespace UniverseLib
{
	public static class ReflectionExtensions
	{
		public static Type GetActualType(this object obj)
		{
			return ReflectionUtility.Instance.Internal_GetActualType(obj);
		}

		public static object TryCast(this object obj)
		{
			return ReflectionUtility.Instance.Internal_TryCast(obj, ReflectionUtility.Instance.Internal_GetActualType(obj));
		}

		public static object TryCast(this object obj, Type castTo)
		{
			return ReflectionUtility.Instance.Internal_TryCast(obj, castTo);
		}

		public static T TryCast<T>(this object obj)
		{
			try
			{
				return (T)ReflectionUtility.Instance.Internal_TryCast(obj, typeof(T));
			}
			catch
			{
				return default(T);
			}
		}

		[Obsolete("This method is no longer necessary, just use Assembly.GetTypes().", false)]
		public static IEnumerable<Type> TryGetTypes(this Assembly asm)
		{
			return asm.GetTypes();
		}

		public static bool ReferenceEqual(this object objA, object objB)
		{
			if (objA == objB)
			{
				return true;
			}
			Object val = (Object)((objA is Object) ? objA : null);
			if (val != null)
			{
				Object val2 = (Object)((objB is Object) ? objB : null);
				if (val2 != null && Object.op_Implicit(val) && Object.op_Implicit(val2) && val.m_CachedPtr == val2.m_CachedPtr)
				{
					return true;
				}
			}
			return false;
		}

		public static string ReflectionExToString(this Exception e, bool innerMost = true)
		{
			if (e == null)
			{
				return "The exception was null.";
			}
			if (innerMost)
			{
				e = e.GetInnerMostException();
			}
			return $"{e.GetType()}: {e.Message}";
		}

		public static Exception GetInnerMostException(this Exception e)
		{
			while (e != null && e.InnerException != null)
			{
				e = e.InnerException;
			}
			return e;
		}
	}
	internal static class ReflectionPatches
	{
		internal static void Init()
		{
			Universe.Patch(typeof(Assembly), "GetTypes", (MethodType)0, new Type[0], null, null, AccessTools.Method(typeof(ReflectionPatches), "Finalizer_Assembly_GetTypes", (Type[])null, (Type[])null));
		}

		public static Exception Finalizer_Assembly_GetTypes(Assembly __instance, Exception __exception, ref Type[] __result)
		{
			if (__exception != null)
			{
				if (__exception is ReflectionTypeLoadException e)
				{
					__result = ReflectionUtility.TryExtractTypesFromException(e);
				}
				else
				{
					try
					{
						__result = __instance.GetExportedTypes();
					}
					catch (ReflectionTypeLoadException e2)
					{
						__result = ReflectionUtility.TryExtractTypesFromException(e2);
					}
					catch
					{
						__result = ArgumentUtility.EmptyTypes;
					}
				}
			}
			return null;
		}
	}
	public class ReflectionUtility
	{
		public static bool Initializing;

		public const BindingFlags FLAGS = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		public static readonly SortedDictionary<string, Type> AllTypes = new SortedDictionary<string, Type>(StringComparer.OrdinalIgnoreCase);

		public static readonly List<string> AllNamespaces = new List<string>();

		private static readonly HashSet<string> uniqueNamespaces = new HashSet<string>();

		private static string[] allTypeNamesArray;

		private static readonly Dictionary<string, Type> shorthandToType = new Dictionary<string, Type>
		{
			{
				"object",
				typeof(object)
			},
			{
				"string",
				typeof(string)
			},
			{
				"bool",
				typeof(bool)
			},
			{
				"byte",
				typeof(byte)
			},
			{
				"sbyte",
				typeof(sbyte)
			},
			{
				"char",
				typeof(char)
			},
			{
				"decimal",
				typeof(decimal)
			},
			{
				"double",
				typeof(double)
			},
			{
				"float",
				typeof(float)
			},
			{
				"int",
				typeof(int)
			},
			{
				"uint",
				typeof(uint)
			},
			{
				"long",
				typeof(long)
			},
			{
				"ulong",
				typeof(ulong)
			},
			{
				"short",
				typeof(short)
			},
			{
				"ushort",
				typeof(ushort)
			},
			{
				"void",
				typeof(void)
			}
		};

		internal static readonly Dictionary<string, Type[]> baseTypes = new Dictionary<string, Type[]>();

		internal static ReflectionUtility Instance { get; private set; }

		public static event Action<Type> OnTypeLoaded;

		internal static void Init()
		{
			ReflectionPatches.Init();
			Instance = new ReflectionUtility();
			Instance.Initialize();
		}

		protected virtual void Initialize()
		{
			SetupTypeCache();
			Initializing = false;
		}

		public static string[] GetTypeNameArray()
		{
			if (allTypeNamesArray == null || allTypeNamesArray.Length != AllTypes.Count)
			{
				allTypeNamesArray = new string[AllTypes.Count];
				int num = 0;
				foreach (string key in AllTypes.Keys)
				{
					allTypeNamesArray[num] = key;
					num++;
				}
			}
			return allTypeNamesArray;
		}

		private static void SetupTypeCache()
		{
			if (Universe.Context == RuntimeContext.Mono)
			{
				ForceLoadManagedAssemblies();
			}
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly asm in assemblies)
			{
				CacheTypes(asm);
			}
			AppDomain.CurrentDomain.AssemblyLoad += AssemblyLoaded;
		}

		private static void AssemblyLoaded(object sender, AssemblyLoadEventArgs args)
		{
			if ((object)args.LoadedAssembly != null && !(args.LoadedAssembly.GetName().Name == "completions"))
			{
				CacheTypes(args.LoadedAssembly);
			}
		}

		private static void ForceLoadManagedAssemblies()
		{
			string path = Path.Combine(Application.dataPath, "Managed");
			if (!Directory.Exists(path))
			{
				return;
			}
			string[] files = Directory.GetFiles(path, "*.dll");
			foreach (string path2 in files)
			{
				try
				{
					Assembly assembly = Assembly.LoadFile(path2);
					assembly.GetTypes();
				}
				catch
				{
				}
			}
		}

		internal static void CacheTypes(Assembly asm)
		{
			Type[] types = asm.GetTypes();
			foreach (Type type in types)
			{
				if (!string.IsNullOrEmpty(type.Namespace) && !uniqueNamespaces.Contains(type.Namespace))
				{
					uniqueNamespaces.Add(type.Namespace);
					int j;
					for (j = 0; j < AllNamespaces.Count && type.Namespace.CompareTo(AllNamespaces[j]) >= 0; j++)
					{
					}
					AllNamespaces.Insert(j, type.Namespace);
				}
				AllTypes[type.FullName] = type;
				ReflectionUtility.OnTypeLoaded?.Invoke(type);
			}
		}

		public static Type GetTypeByName(string fullName)
		{
			return Instance.Internal_GetTypeByName(fullName);
		}

		internal virtual Type Internal_GetTypeByName(string fullName)
		{
			if (shorthandToType.TryGetValue(fullName, out var value))
			{
				return value;
			}
			AllTypes.TryGetValue(fullName, out var value2);
			if ((object)value2 == null)
			{
				value2 = Type.GetType(fullName);
			}
			return value2;
		}

		internal virtual Type Internal_GetActualType(object obj)
		{
			return obj?.GetType();
		}

		internal virtual object Internal_TryCast(object obj, Type castTo)
		{
			return obj;
		}

		public static string ProcessTypeInString(Type type, string theString)
		{
			return Instance.Internal_ProcessTypeInString(theString, type);
		}

		internal virtual string Internal_ProcessTypeInString(string theString, Type type)
		{
			return theString;
		}

		public static void FindSingleton(string[] possibleNames, Type type, BindingFlags flags, List<object> instances)
		{
			Instance.Internal_FindSingleton(possibleNames, type, flags, instances);
		}

		internal virtual void Internal_FindSingleton(string[] possibleNames, Type type, BindingFlags flags, List<object> instances)
		{
			foreach (string name in possibleNames)
			{
				FieldInfo field = type.GetField(name, flags);
				if ((object)field != null)
				{
					object value = field.GetValue(null);
					if (value != null)
					{
						instances.Add(value);
						break;
					}
				}
			}
		}

		public static Type[] TryExtractTypesFromException(ReflectionTypeLoadException e)
		{
			try
			{
				return e.Types.Where((Type it) => (object)it != null).ToArray();
			}
			catch
			{
				return ArgumentUtility.EmptyTypes;
			}
		}

		public static Type[] GetAllBaseTypes(object obj)
		{
			return GetAllBaseTypes(obj?.GetActualType());
		}

		public static Type[] GetAllBaseTypes(Type type)
		{
			if ((object)type == null)
			{
				throw new ArgumentNullException("type");
			}
			string assemblyQualifiedName = type.AssemblyQualifiedName;
			if (baseTypes.TryGetValue(assemblyQualifiedName, out var value))
			{
				return value;
			}
			List<Type> list = new List<Type>();
			while ((object)type != null)
			{
				list.Add(type);
				type = type.BaseType;
			}
			value = list.ToArray();
			baseTypes.Add(assemblyQualifiedName, value);
			return value;
		}

		public static void GetImplementationsOf(Type baseType, Action<HashSet<Type>> onResultsFetched, bool allowAbstract, bool allowGeneric, bool allowEnum)
		{
			RuntimeHelper.StartCoroutine(DoGetImplementations(onResultsFetched, baseType, allowAbstract, allowGeneric, allowEnum));
		}

		private static IEnumerator DoGetImplementations(Action<HashSet<Type>> onResultsFetched, Type baseType, bool allowAbstract, bool allowGeneric, bool allowEnum)
		{
			List<Type> resolvedTypes = new List<Type>();
			OnTypeLoaded += ourListener;
			HashSet<Type> set = new HashSet<Type>();
			IEnumerator coro2 = GetImplementationsAsync(baseType, set, allowAbstract, allowGeneric, allowEnum, DefaultTypesEnumerator());
			while (coro2.MoveNext())
			{
				yield return null;
			}
			OnTypeLoaded -= ourListener;
			if (resolvedTypes.Count > 0)
			{
				coro2 = GetImplementationsAsync(baseType, set, allowAbstract, allowGeneric, allowEnum, resolvedTypes.GetEnumerator());
				while (coro2.MoveNext())
				{
					yield return null;
				}
			}
			onResultsFetched(set);
			void ourListener(Type t)
			{
				resolvedTypes.Add(t);
			}
		}

		private static IEnumerator<Type> DefaultTypesEnumerator()
		{
			string[] names = GetTypeNameArray();
			foreach (string name in names)
			{
				yield return AllTypes[name];
			}
		}

		private static IEnumerator GetImplementationsAsync(Type baseType, HashSet<Type> set, bool allowAbstract, bool allowGeneric, bool allowEnum, IEnumerator<Type> enumerator)
		{
			Stopwatch sw = new Stopwatch();
			sw.Start();
			bool isGenericParam = baseType?.IsGenericParameter ?? false;
			while (enumerator.MoveNext())
			{
				if (sw.ElapsedMilliseconds > 10)
				{
					yield return null;
					sw.Reset();
					sw.Start();
				}
				try
				{
					Type type = enumerator.Current;
					if (set.Contains(type) || (!allowAbstract && type.IsAbstract) || (!allowGeneric && type.IsGenericType) || (!allowEnum && type.IsEnum) || type.FullName.Contains("PrivateImplementationDetails") || type.FullName.Contains("DisplayClass") || Enumerable.Contains(type.FullName, '<'))
					{
						continue;
					}
					if (!isGenericParam)
					{
						if ((object)baseType == null || baseType.IsAssignableFrom(type))
						{
							goto IL_0269;
						}
					}
					else if ((!type.IsClass || !MiscUtility.HasFlag(baseType.GenericParameterAttributes, GenericParameterAttributes.NotNullableValueTypeConstraint)) && (!type.IsValueType || !MiscUtility.HasFlag(baseType.GenericParameterAttributes, GenericParameterAttributes.ReferenceTypeConstraint)) && !baseType.GetGenericParameterConstraints().Any((Type it) => !it.IsAssignableFrom(type)))
					{
						goto IL_0269;
					}
					goto end_IL_009f;
					IL_0269:
					set.Add(type);
					end_IL_009f:;
				}
				catch
				{
				}
			}
		}

		public static bool IsEnumerable(Type type)
		{
			return Instance.Internal_IsEnumerable(type);
		}

		protected virtual bool Internal_IsEnumerable(Type type)
		{
			return typeof(IEnumerable).IsAssignableFrom(type);
		}

		public static bool TryGetEnumerator(object ienumerable, out IEnumerator enumerator)
		{
			return Instance.Internal_TryGetEnumerator(ienumerable, out enumerator);
		}

		protected virtual bool Internal_TryGetEnumerator(object list, out IEnumerator enumerator)
		{
			enumerator = (list as IEnumerable).GetEnumerator();
			return true;
		}

		public static bool TryGetEntryType(Type enumerableType, out Type type)
		{
			return Instance.Internal_TryGetEntryType(enumerableType, out type);
		}

		protected virtual bool Internal_TryGetEntryType(Type enumerableType, out Type type)
		{
			if (enumerableType.IsArray)
			{
				type = enumerableType.GetElementType();
				return true;
			}
			Type[] interfaces = enumerableType.GetInterfaces();
			foreach (Type type2 in interfaces)
			{
				if (type2.IsGenericType)
				{
					Type genericTypeDefinition = type2.GetGenericTypeDefinition();
					if ((object)genericTypeDefinition == typeof(IEnumerable<>) || (object)genericTypeDefinition == typeof(IList<>) || (object)genericTypeDefinition == typeof(ICollection<>))
					{
						type = type2.GetGenericArguments()[0];
						return true;
					}
				}
			}
			type = typeof(object);
			return false;
		}

		public static bool IsDictionary(Type type)
		{
			return Instance.Internal_IsDictionary(type);
		}

		protected virtual bool Internal_IsDictionary(Type type)
		{
			return typeof(IDictionary).IsAssignableFrom(type);
		}

		public static bool TryGetDictEnumerator(object dictionary, out IEnumerator<DictionaryEntry> dictEnumerator)
		{
			return Instance.Internal_TryGetDictEnumerator(dictionary, out dictEnumerator);
		}

		protected virtual bool Internal_TryGetDictEnumerator(object dictionary, out IEnumerator<DictionaryEntry> dictEnumerator)
		{
			dictEnumerator = EnumerateDictionary((IDictionary)dictionary);
			return true;
		}

		private IEnumerator<DictionaryEntry> EnumerateDictionary(IDictionary dict)
		{
			IDictionaryEnumerator enumerator = dict.GetEnumerator();
			while (enumerator.MoveNext())
			{
				yield return new DictionaryEntry(enumerator.Key, enumerator.Value);
			}
		}

		public static bool TryGetEntryTypes(Type dictionaryType, out Type keys, out Type values)
		{
			return Instance.Internal_TryGetEntryTypes(dictionaryType, out keys, out values);
		}

		protected virtual bool Internal_TryGetEntryTypes(Type dictionaryType, out Type keys, out Type values)
		{
			Type[] interfaces = dictionaryType.GetInterfaces();
			foreach (Type type in interfaces)
			{
				if (type.IsGenericType && (object)type.GetGenericTypeDefinition() == typeof(IDictionary<, >))
				{
					Type[] genericArguments = type.GetGenericArguments();
					keys = genericArguments[0];
					values = genericArguments[1];
					return true;
				}
			}
			keys = typeof(object);
			values = typeof(object);
			return false;
		}
	}
	public abstract class RuntimeHelper
	{
		internal static RuntimeHelper Instance { get; private set; }

		internal static void Init()
		{
			Instance = new MonoProvider();
			Instance.OnInitialize();
		}

		protected internal abstract void OnInitialize();

		public static Coroutine StartCoroutine(IEnumerator routine)
		{
			return Instance.Internal_StartCoroutine(routine);
		}

		protected internal abstract Coroutine Internal_StartCoroutine(IEnumerator routine);

		public static void StopCoroutine(Coroutine coroutine)
		{
			Instance.Internal_StopCoroutine(coroutine);
		}

		protected internal abstract void Internal_StopCoroutine(Coroutine coroutine);

		public static T AddComponent<T>(GameObject obj, Type type) where T : Component
		{
			return Instance.Internal_AddComponent<T>(obj, type);
		}

		protected internal abstract T Internal_AddComponent<T>(GameObject obj, Type type) where T : Component;

		public static ScriptableObject CreateScriptable(Type type)
		{
			return Instance.Internal_CreateScriptable(type);
		}

		protected internal abstract ScriptableObject Internal_CreateScriptable(Type type);

		public static string LayerToName(int layer)
		{
			return Instance.Internal_LayerToName(layer);
		}

		protected internal abstract string Internal_LayerToName(int layer);

		public static T[] FindObjectsOfTypeAll<T>() where T : Object
		{
			return Instance.Internal_FindObjectsOfTypeAll<T>();
		}

		public static Object[] FindObjectsOfTypeAll(Type type)
		{
			return Instance.Internal_FindObjectsOfTypeAll(type);
		}

		protected internal abstract T[] Internal_FindObjectsOfTypeAll<T>() where T : Object;

		protected internal abstract Object[] Internal_FindObjectsOfTypeAll(Type type);

		public static void GraphicRaycast(GraphicRaycaster raycaster, PointerEventData data, List<RaycastResult> list)
		{
			Instance.Internal_GraphicRaycast(raycaster, data, list);
		}

		protected internal abstract void Internal_GraphicRaycast(GraphicRaycaster raycaster, PointerEventData data, List<RaycastResult> list);

		public static GameObject[] GetRootGameObjects(Scene scene)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return Instance.Internal_GetRootGameObjects(scene);
		}

		protected internal abstract GameObject[] Internal_GetRootGameObjects(Scene scene);

		public static int GetRootCount(Scene scene)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return Instance.Internal_GetRootCount(scene);
		}

		protected internal abstract int Internal_GetRootCount(Scene scene);

		public static void SetColorBlockAuto(Selectable selectable, Color baseColor)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Instance.Internal_SetColorBlock(selectable, baseColor, baseColor * 1.2f, baseColor * 0.8f);
		}

		public static void SetColorBlock(Selectable selectable, ColorBlock colors)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Instance.Internal_SetColorBlock(selectable, colors);
		}

		protected internal abstract void Internal_SetColorBlock(Selectable selectable, ColorBlock colors);

		public static void SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null, Color? disabled = null)
		{
			Instance.Internal_SetColorBlock(selectable, normal, highlighted, pressed, disabled);
		}

		protected internal abstract void Internal_SetColorBlock(Selectable selectable, Color? normal = null, Color? highlighted = null, Color? pressed = null, Color? disabled = null);
	}
	internal class UniversalBehaviour : MonoBehaviour
	{
		internal static UniversalBehaviour Instance { get; private set; }

		internal static void Setup()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("UniverseLibBehaviour");
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D);
			Instance = val.AddComponent<UniversalBehaviour>();
		}

		internal void Update()
		{
			Universe.Update();
		}
	}
	public class Universe
	{
		public enum GlobalState
		{
			WaitingToSetup,
			SettingUp,
			SetupCompleted
		}

		public const string NAME = "UniverseLib";

		public const string VERSION = "1.5.1";

		public const string AUTHOR = "Sinai";

		public const string GUID = "com.sinai.universelib";

		private static float startupDelay;

		private static Action<string, LogType> logHandler;

		public static RuntimeContext Context { get; } = RuntimeContext.Mono;


		public static GlobalState CurrentGlobalState { get; private set; }

		internal static Harmony Harmony { get; } = new Harmony("com.sinai.universelib");


		private static event Action OnInitialized;

		public static void Init(Action onInitialized = null, Action<string, LogType> logHandler = null)
		{
			Init(1f, onInitialized, logHandler, default(UniverseLibConfig));
		}

		public static void Init(float startupDelay, Action onInitialized, Action<string, LogType> logHandler, UniverseLibConfig config)
		{
			if (CurrentGlobalState == GlobalState.SetupCompleted)
			{
				InvokeOnInitialized(onInitialized);
				return;
			}
			if (startupDelay > Universe.startupDelay)
			{
				Universe.startupDelay = startupDelay;
			}
			ConfigManager.LoadConfig(config);
			OnInitialized += onInitialized;
			if (logHandler != null && Universe.logHandler == null)
			{
				Universe.logHandler = logHandler;
			}
			if (CurrentGlobalState == GlobalState.WaitingToSetup)
			{
				CurrentGlobalState = GlobalState.SettingUp;
				Log("UniverseLib 1.5.1 initializing...");
				UniversalBehaviour.Setup();
				ReflectionUtility.Init();
				RuntimeHelper.Init();
				RuntimeHelper.Instance.Internal_StartCoroutine(SetupCoroutine());
				Log("Finished UniverseLib initial setup.");
			}
		}

		internal static void Update()
		{
			UniversalUI.Update();
		}

		private static IEnumerator SetupCoroutine()
		{
			yield return null;
			Stopwatch sw = new Stopwatch();
			sw.Start();
			while (ReflectionUtility.Initializing || (float)sw.ElapsedMilliseconds * 0.001f < startupDelay)
			{
				yield return null;
			}
			InputManager.Init();
			UniversalUI.Init();
			Log("UniverseLib 1.5.1 initialized.");
			CurrentGlobalState = GlobalState.SetupCompleted;
			InvokeOnInitialized(Universe.OnInitialized);
		}

		private static void InvokeOnInitialized(Action onInitialized)
		{
			if (onInitialized == null)
			{
				return;
			}
			Delegate[] invocationList = onInitialized.GetInvocationList();
			foreach (Delegate @delegate in invocationList)
			{
				try
				{
					@delegate.DynamicInvoke();
				}
				catch (Exception arg)
				{
					LogWarning($"Exception invoking onInitialized callback! {arg}");
				}
			}
		}

		internal static void Log(object message)
		{
			Log(message, (LogType)3);
		}

		internal static void LogWarning(object message)
		{
			Log(message, (LogType)2);
		}

		internal static void LogError(object message)
		{
			Log(message, (LogType)0);
		}

		private static void Log(object message, LogType logType)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			logHandler("[UniverseLib] " + (message?.ToString() ?? string.Empty), logType);
		}

		internal static bool Patch(Type type, string methodName, MethodType methodType, Type[] arguments = null, MethodInfo prefix = null, MethodInfo postfix = null, MethodInfo finalizer = null)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			try
			{
				string text = (((int)methodType == 1) ? "get_" : (((int)methodType != 2) ? string.Empty : "set_"));
				string text2 = text;
				MethodInfo methodInfo = ((arguments == null) ? type.GetMethod(text2 + methodName, AccessTools.all) : type.GetMethod(text2 + methodName, AccessTools.all, null, arguments, null));
				if ((object)methodInfo == null)
				{
					return false;
				}
				PatchProcessor val = Harmony.CreateProcessor((MethodBase)methodInfo);
				if ((object)prefix != null)
				{
					val.AddPrefix(new HarmonyMethod(prefix));
				}
				if ((object)postfix != null)
				{
					val.AddPostfix(new HarmonyMethod(postfix));
				}
				if ((object)finalizer != null)
				{
					val.AddFinalizer(new HarmonyMethod(finalizer));
				}
				val.Patch();
				return true;
			}
			catch (Exception arg)
			{
				LogWarning($"\t Exception patching {type.FullName}.{methodName}: {arg}");
				return false;
			}
		}

		internal static bool Patch(Type type, string[] possibleNames, MethodType methodType, Type[] arguments = null, MethodInfo prefix = null, MethodInfo postfix = null, MethodInfo finalizer = null)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			foreach (string methodName in possibleNames)
			{
				if (Patch(type, methodName, methodType, arguments, prefix, postfix, finalizer))
				{
					return true;
				}
			}
			return false;
		}

		internal static bool Patch(Type type, string[] possibleNames, MethodType methodType, Type[][] possibleArguments, MethodInfo prefix = null, MethodInfo postfix = null, MethodInfo finalizer = null)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			foreach (string methodName in possibleNames)
			{
				foreach (Type[] arguments in possibleArguments)
				{
					if (Patch(type, methodName, methodType, arguments, prefix, postfix, finalizer))
					{
						return true;
					}
				}
			}
			return false;
		}

		internal static bool Patch(Type type, string methodName, MethodType methodType, Type[][] possibleArguments, MethodInfo prefix = null, MethodInfo postfix = null, MethodInfo finalizer = null)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			foreach (Type[] arguments in possibleArguments)
			{
				if (Patch(type, methodName, methodType, arguments, prefix, postfix, finalizer))
				{
					return true;
				}
			}
			return false;
		}
	}
}
namespace UniverseLib.Utility
{
	public static class ArgumentUtility
	{
		public static readonly Type[] EmptyTypes = new Type[0];

		public static readonly object[] EmptyArgs = new object[0];

		public static readonly Type[] ParseArgs = new Type[1] { typeof(string) };
	}
	public static class IOUtility
	{
		private static readonly char[] invalidDirectoryCharacters = Path.GetInvalidPathChars();

		private static readonly char[] invalidFilenameCharacters = Path.GetInvalidFileNameChars();

		public static string EnsureValidFilePath(string fullPathWithFile)
		{
			fullPathWithFile = string.Concat(fullPathWithFile.Split(invalidDirectoryCharacters));
			Directory.CreateDirectory(Path.GetDirectoryName(fullPathWithFile));
			return fullPathWithFile;
		}

		public static string EnsureValidFilename(string filename)
		{
			return string.Concat(filename.Split(invalidFilenameCharacters));
		}
	}
	public static class MiscUtility
	{
		public static bool ContainsIgnoreCase(this string _this, string s)
		{
			return CultureInfo.CurrentCulture.CompareInfo.IndexOf(_this, s, CompareOptions.IgnoreCase) >= 0;
		}

		public static bool HasFlag(this Enum flags, Enum value)
		{
			try
			{
				ulong num = Convert.ToUInt64(value);
				return (Convert.ToUInt64(flags) & num) == num;
			}
			catch
			{
				long num2 = Convert.ToInt64(value);
				return (Convert.ToInt64(flags) & num2) == num2;
			}
		}

		public static bool EndsWith(this StringBuilder sb, string _string)
		{
			int length = _string.Length;
			if (sb.Length < length)
			{
				return false;
			}
			int num = 0;
			int num2 = sb.Length - length;
			while (num2 < sb.Length)
			{
				if (sb[num2] != _string[num])
				{
					return false;
				}
				num2++;
				num++;
			}
			return true;
		}
	}
	public static class ParseUtility
	{
		internal delegate object ParseMethod(string input);

		internal delegate string ToStringMethod(object obj);

		public static readonly string NumberFormatString = "0.####";

		private static readonly Dictionary<int, string> numSequenceStrings = new Dictionary<int, string>();

		private static readonly HashSet<Type> nonPrimitiveTypes = new HashSet<Type>
		{
			typeof(string),
			typeof(decimal),
			typeof(DateTime)
		};

		private static readonly HashSet<Type> formattedTypes = new HashSet<Type>
		{
			typeof(float),
			typeof(double),
			typeof(decimal)
		};

		private static readonly Dictionary<string, string> typeInputExamples = new Dictionary<string, string>();

		private static readonly Dictionary<string, ParseMethod> customTypes = new Dictionary<string, ParseMethod>
		{
			{
				typeof(Vector2).FullName,
				TryParseVector2
			},
			{
				typeof(Vector3).FullName,
				TryParseVector3
			},
			{
				typeof(Vector4).FullName,
				TryParseVector4
			},
			{
				typeof(Quaternion).FullName,
				TryParseQuaternion
			},
			{
				typeof(Rect).FullName,
				TryParseRect
			},
			{
				typeof(Color).FullName,
				TryParseColor
			},
			{
				typeof(Color32).FullName,
				TryParseColor32
			},
			{
				typeof(LayerMask).FullName,
				TryParseLayerMask
			}
		};

		private static readonly Dictionary<string, ToStringMethod> customTypesToString = new Dictionary<string, ToStringMethod>
		{
			{
				typeof(Vector2).FullName,
				Vector2ToString
			},
			{
				typeof(Vector3).FullName,
				Vector3ToString
			},
			{
				typeof(Vector4).FullName,
				Vector4ToString
			},
			{
				typeof(Quaternion).FullName,
				QuaternionToString
			},
			{
				typeof(Rect).FullName,
				RectToString
			},
			{
				typeof(Color).FullName,
				ColorToString
			},
			{
				typeof(Color32).FullName,
				Color32ToString
			},
			{
				typeof(LayerMask).FullName,
				LayerMaskToString
			}
		};

		public static string FormatDecimalSequence(params object[] numbers)
		{
			if (numbers.Length == 0)
			{
				return null;
			}
			return string.Format(CultureInfo.CurrentCulture, GetSequenceFormatString(numbers.Length), numbers);
		}

		internal static string GetSequenceFormatString(int count)
		{
			if (count <= 0)
			{
				return null;
			}
			if (numSequenceStrings.ContainsKey(count))
			{
				return numSequenceStrings[count];
			}
			string[] array = new string[count];
			for (int i = 0; i < count; i++)
			{
				array[i] = $"{{{i}:{NumberFormatString}}}";
			}
			string text = string.Join(" ", array);
			numSequenceStrings.Add(count, text);
			return text;
		}

		public static bool CanParse(Type type)
		{
			return !string.IsNullOrEmpty(type?.FullName) && (type.IsPrimitive || type.IsEnum || nonPrimitiveTypes.Contains(type) || customTypes.ContainsKey(type.FullName));
		}

		public static bool CanParse<T>()
		{
			return CanParse(typeof(T));
		}

		public static bool TryParse<T>(string input, out T obj, out Exception parseException)
		{
			object obj2;
			bool result = TryParse(input, typeof(T), out obj2, out parseException);
			if (obj2 != null)
			{
				obj = (T)obj2;
			}
			else
			{
				obj = default(T);
			}
			return result;
		}

		public static bool TryParse(string input, Type type, out object obj, out Exception parseException)
		{
			obj = null;
			parseException = null;
			if ((object)type == null)
			{
				return false;
			}
			if ((object)type == typeof(string))
			{
				obj = input;
				return true;
			}
			if (type.IsEnum)
			{
				try
				{
					obj = Enum.Parse(type, input);
					return true;
				}
				catch (Exception e)
				{
					parseException = e.GetInnerMostException();
					return false;
				}
			}
			try
			{
				if (customTypes.ContainsKey(type.FullName))
				{
					obj = customTypes[type.FullName](input);
				}
				else
				{
					obj = AccessTools.Method(type, "Parse", ArgumentUtility.ParseArgs, (Type[])null).Invoke(null, new object[1] { input });
				}
				return true;
			}
			catch (Exception e2)
			{
				Exception innerMostException = e2.GetInnerMostException();
				parseException = innerMostException;
			}
			return false;
		}

		public static string ToStringForInput<T>(object obj)
		{
			return ToStringForInput(obj, typeof(T));
		}

		public static string ToStringForInput(object obj, Type type)
		{
			if ((object)type == null || obj == null)
			{
				return null;
			}
			if ((object)type == typeof(string))
			{
				return obj as string;
			}
			if (type.IsEnum)
			{
				return Enum.IsDefined(type, obj) ? Enum.GetName(type, obj) : obj.ToString();
			}
			try
			{
				if (customTypes.ContainsKey(type.FullName))
				{
					return customTypesToString[type.FullName](obj);
				}
				if (formattedTypes.Contains(type))
				{
					return AccessTools.Method(type, "ToString", new Type[2]
					{
						typeof(string),
						typeof(IFormatProvider)
					}, (Type[])null).Invoke(obj, new object[2]
					{
						NumberFormatString,
						CultureInfo.CurrentCulture
					}) as string;
				}
				return obj.ToString();
			}
			catch (Exception arg)
			{
				Universe.LogWarning($"Exception formatting object for input: {arg}");
				return null;
			}
		}

		public static string GetExampleInput<T>()
		{
			return GetExampleInput(typeof(T));
		}

		public static string GetExampleInput(Type type)
		{
			if (!typeInputExamples.ContainsKey(type.AssemblyQualifiedName))
			{
				try
				{
					if (type.IsEnum)
					{
						typeInputExamples.Add(type.AssemblyQualifiedName, Enum.GetNames(type).First());
					}
					else
					{
						object obj = Activator.CreateInstance(type);
						typeInputExamples.Add(type.AssemblyQualifiedName, ToStringForInput(obj, type));
					}
				}
				catch (Exception message)
				{
					Universe.LogWarning("Exception generating default instance for example input for '" + type.FullName + "'");
					Universe.Log(message);
					return "";
				}
			}
			return typeInputExamples[type.AssemblyQualifiedName];
		}

		internal static object TryParseVector2(string input)
		{
			//IL_0003: 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)
			Vector2 val = default(Vector2);
			string[] array = input.Split(new char[1] { ' ' });
			val.x = float.Parse(array[0].Trim(), CultureInfo.CurrentCulture);
			val.y = float.Parse(array[1].Trim(), CultureInfo.CurrentCulture);
			return val;
		}

		internal static string Vector2ToString(object obj)
		{
			//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_0027: 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)
			if (!(obj is Vector2 val) || 1 == 0)
			{
				return null;
			}
			return FormatDecimalSequence(val.x, val.y);
		}

		internal static object TryParseVector3(string input)
		{
			//IL_0003: 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)
			Vector3 val = default(Vector3);
			string[] array = input.Split(new char[1] { ' ' });
			val.x = float.Parse(array[0].Trim(), CultureInfo.CurrentCulture);
			val.y = float.Parse(array[1].Trim(), CultureInfo.CurrentCulture);
			val.z = float.Parse(array[2].Trim(), CultureInfo.CurrentCulture);
			return val;
		}

		internal static string Vector3ToString(object obj)
		{
			//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_0027: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!(obj is Vector3 val) || 1 == 0)
			{
				return null;
			}
			return FormatDecimalSequence(val.x, val.y, val.z);
		}

		internal static object TryParseVector4(string input)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			Vector4 val = default(Vector4);
			string[] array = input.Split(new char[1] { ' ' });
			val.x = float.Parse(array[0].Trim(), CultureInfo.CurrentCulture);
			val.y = float.Parse(array[1].Trim(), CultureInfo.CurrentCulture);
			val.z = float.Parse(array[2].Trim(), CultureInfo.CurrentCulture);
			val.w = float.Parse(array[3].Trim(), CultureInfo.CurrentCulture);
			return val;
		}

		internal static string Vector4ToString(object obj)
		{
			//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_0027: 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_0043: 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)
			if (!(obj is Vector4 val) || 1 == 0)
			{
				return null;
			}
			return FormatDecimalSequence(val.x, val.y, val.z, val.w);
		}

		internal static object TryParseQuaternion(string input)
		{
			//IL_0003: 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_00e9: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			string[] array = input.Split(new char[1] { ' ' });
			if (array.Length == 4)
			{
				Quaternion val2 = default(Quaternion);
				val2.x = float.Parse(array[0].Trim(), CultureInfo.CurrentCulture);
				val2.y = float.Parse(array[1].Trim(), CultureInfo.CurrentCulture);
				val2.z = float.Parse(array[2].Trim(), CultureInfo.CurrentCulture);
				val2.w = float.Parse(array[3].Trim(), CultureInfo.CurrentCulture);
				return val2;
			}
			val.x = float.Parse(array[0].Trim(), CultureInfo.CurrentCulture);
			val.y = float.Parse(array[1].Trim(), CultureInfo.CurrentCulture);
			val.z = float.Parse(array[2].Trim(), CultureInfo.CurrentCulture);
			return Quaternion.Euler(val);
		}

		internal static string QuaternionToString(object obj)
		{
			//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_0021: 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_002f: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!(obj is Quaternion val) || 1 == 0)
			{
				return null;
			}
			Vector3 eulerAngles = ((Quaternion)(ref val)).eulerAngles;
			return FormatDecimalSequence(eulerAngles.x, eulerAngles.y, eulerAngles.z);
		}

		internal static object TryParseRect(string input)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			string[] array = input.Split(new char[1] { ' ' });
			((Rect)(ref val)).x = float.Parse(array[0].Trim(), CultureInfo.CurrentCulture);
			((Rect)(ref val)).y = float.Parse(array[1].Trim(), CultureInfo.CurrentCulture);
			((Rect)(ref val)).width = float.Parse(array[2].Trim(), CultureInfo.CurrentCulture);
			((Rect)(ref val)).height = float.Parse(array[3].Trim(), CultureInfo.CurrentCulture);
			return val;
		}

		internal static string RectToString(object obj)
		{
			//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)
			if (!(obj is Rect val) || 1 == 0)
			{
				return null;
			}
			return FormatDecimalSequence(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, ((Rect)(ref val)).height);
		}

		internal static object TryParseColor(string input)
		{
			//IL_0003: 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)
			Color val = default(Color);
			string[] array = input.Split(new char[1] { ' ' });
			val.r = float.Parse(array[0].Trim(), CultureInfo.CurrentCulture);
			val.g = float.Parse(array[1].Trim(), CultureInfo.CurrentCulture);
			val.b = float.Parse(array[2].Trim(), CultureInfo.CurrentCulture);
			if (array.Length > 3)
			{
				val.a = float.Parse(array[3].Trim(), CultureInfo.CurrentCulture);
			}
			else
			{
				val.a = 1f;
			}
			return val;
		}

		internal static string ColorToString(object obj)
		{
			//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_0027: 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_0043: 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)
			if (!(obj is Color val) || 1 == 0)
			{
				return null;
			}
			return FormatDecimalSequence(val.r, val.g, val.b, val.a);
		}

		internal static object TryParseColor32(string input)
		{
			//IL_0003: 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)
			Color32 val = default(Color32);
			string[] array = input.Split(new char[1] { ' ' });
			val.r = byte.Parse(array[0].Trim(), CultureInfo.CurrentCulture);
			val.g = byte.Parse(array[1].Trim(), CultureInfo.CurrentCulture);
			val.b = byte.Parse(array[2].Trim(), CultureInfo.CurrentCulture);
			if (array.Length > 3)
			{
				val.a = byte.Parse(array[3].Trim(), CultureInfo.CurrentCulture);
			}
			else
			{
				val.a = byte.MaxValue;
			}
			return val;
		}

		internal static string Color32ToString(object obj)
		{
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			if (!(obj is Color32 val) || 1 == 0)
			{
				return null;
			}
			return $"{val.r} {val.g} {val.b} {val.a}";
		}

		internal static object TryParseLayerMask(string input)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return LayerMask.op_Implicit(int.Parse(input));
		}

		internal static string LayerMaskToString(object obj)
		{
			//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)
			if (!(obj is LayerMask val) || 1 == 0)
			{
				return null;
			}
			return ((LayerMask)(ref val)).value.ToString();
		}
	}
	public static class SignatureHighlighter
	{
		public const string NAMESPACE = "#a8a8a8";

		public const string CONST = "#92c470";

		public const string CLASS_STATIC = "#3a8d71";

		public const string CLASS_INSTANCE = "#2df7b2";

		public const string STRUCT = "#0fba3a";

		public const string INTERFACE = "#9b9b82";

		public const string FIELD_STATIC = "#8d8dc6";

		public const string FIELD_INSTANCE = "#c266ff";

		public const string METHOD_STATIC = "#b55b02";

		public const string METHOD_INSTANCE = "#ff8000";

		public const string PROP_STATIC = "#588075";

		public const string PROP_INSTANCE = "#55a38e";

		public const string LOCAL_ARG = "#a6e9e9";

		public const string OPEN_COLOR = "<color=";

		public const string CLOSE_COLOR = "</color>";

		public const string OPEN_ITALIC = "<i>";

		public const string CLOSE_ITALIC = "</i>";

		public static readonly Regex ArrayTokenRegex = new Regex("\\[,*?\\]");

		private static readonly Regex colorTagRegex = new Regex("<color=#?[\\d|\\w]*>");

		public static readonly Color StringOrange = new Color(0.83f, 0.61f, 0.52f);

		public static readonly Color EnumGreen = new Color(0.57f, 0.76f, 0.43f);

		public static readonly Color KeywordBlue = new Color(0.3f, 0.61f, 0.83f);

		public static readonly string keywordBlueHex = KeywordBlue.ToHex();

		public static readonly Color NumberGreen = new Color(0.71f, 0.8f, 0.65f);

		private static readonly Dictionary<string, string> typeToRichType = new Dictionary<string, string>();

		private static readonly Dictionary<string, string> highlightedMethods = new Dictionary<string, string>();

		private static readonly Dictionary<Type, string> builtInTypesToShorthand = new Dictionary<Type, string>
		{
			{
				typeof(object),
				"object"
			},
			{
				typeof(string),
				"string"
			},
			{
				typeof(bool),
				"bool"
			},
			{
				typeof(byte),
				"byte"
			},
			{
				typeof(sbyte),
				"sbyte"
			},
			{
				typeof(char),
				"char"
			},
			{
				typeof(decimal),
				"decimal"
			},
			{
				typeof(double),
				"double"
			},
			{
				typeof(float),
				"float"
			},
			{
				typeof(int),
				"int"
			},
			{
				typeof(uint),
				"uint"
			},
			{
				typeof(long),
				"long"
			},
			{
				typeof(ulong),
				"ulong"
			},
			{
				typeof(short),
				"short"
			},
			{
				typeof(ushort),
				"ushort"
			},
			{
				typeof(void),
				"void"
			}
		};

		public static string Parse(Type type, bool includeNamespace, MemberInfo memberInfo = null)
		{
			if ((object)type == null)
			{
				throw new ArgumentNullException("type");
			}
			if (memberInfo is MethodInfo method)
			{
				return ParseMethod(method);
			}
			if (memberInfo is ConstructorInfo ctor)
			{
				return ParseConstructor(ctor);
			}
			StringBuilder stringBuilder = new StringBuilder();
			if (type.IsByRef)
			{
				AppendOpenColor(stringBuilder, "#" + keywordBlueHex).Append("ref ").Append("</color>");
			}
			Type type2 = type;
			while (type2.HasElementType)
			{
				type2 = type2.GetElementType();
			}
			includeNamespace &= !builtInTypesToShorthand.ContainsKey(type2);
			if (!type.IsGenericParameter && (!type.HasElementType || !type.GetElementType().IsGenericParameter) && includeNamespace && TryGetNamespace(type, out var ns))
			{
				AppendOpenColor(stringBuilder, "#a8a8a8").Append(ns).Append("</color>").Append('.');
			}
			stringBuilder.Append(ProcessType(type));
			if ((object)memberInfo != null)
			{
				stringBuilder.Append('.');
				int index = stringBuilder.Length - 1;
				AppendOpenColor(stringBuilder, GetMemberInfoColor(memberInfo, out var isStatic)).Append(memberInfo.Name).Append("</color>");
				if (isStatic)
				{
					stringBuilder.Insert(index, "<i>");
					stringBuilder.Append("</i>");
				}
			}
			return stringBuilder.ToString();
		}

		private static string ProcessType(Type type)
		{
			string key = type.ToString();
			if (typeToRichType.ContainsKey(key))
			{
				return typeToRichType[key];
			}
			StringBuilder stringBuilder = new StringBuilder();
			if (!type.IsGenericParameter)
			{
				int length = stringBuilder.Length;
				Type declaringType = type.DeclaringType;
				while ((object)declaringType != null)
				{
					stringBuilder.Insert(length, HighlightType(declaringType) + ".");
					declaringType = declaringType.DeclaringType;
				}
				stringBuilder.Append(HighlightType(type));
				if (type.IsGenericType)
				{
					ProcessGenericArguments(type, stringBuilder);
				}
			}
			else
			{
				stringBuilder.Append("<color=").Append("#92c470").Append('>')
					.Append(type.Name)
					.Append("</color>");
			}
			string text = stringBuilder.ToString();
			typeToRichType.Add(key, text);
			return text;
		}

		internal static string GetClassColor(Type type)
		{
			if (type.IsAbstract && type.IsSealed)
			{
				return "#3a8d71";
			}
			if (type.IsEnum || type.IsGenericParameter)
			{
				return "#92c470";
			}
			if (type.IsValueType)
			{
				return "#0fba3a";
			}
			if (type.IsInterface)
			{
				return "#9b9b82";
			}
			return "#2df7b2";
		}

		private static bool TryGetNamespace(Type type, out string ns)
		{
			return !string.IsNullOrEmpty(ns = type.Namespace?.Trim());
		}

		private static StringBuilder AppendOpenColor(StringBuilder sb, string color)
		{
			return sb.Append("<color=").Append(color).Append('>');
		}

		private static string HighlightType(Type type)
		{
			StringBuilder stringBuilder = new StringBuilder();
			if (type.IsByRef)
			{
				type = type.GetElementType();
			}
			int num = 0;
			Match match = ArrayTokenRegex.Match(type.Name);
			if (match != null && match.Success)
			{
				num = 1 + match.Value.Count((char c) => c == ',');
				type = type.GetElementType();
			}
			if (builtInTypesToShorthand.TryGetValue(type, out var value))
			{
				AppendOpenColor(stringBuilder, "#" + keywordBlueHex).Append(value).Append("</color>");
			}
			else
			{
				stringBuilder.Append("<color=" + GetClassColor(type) + ">").Append(type.Name).Append("</color>");
			}
			if (num > 0)
			{
				stringBuilder.Append('[').Append(new string(',', num - 1)).Append(']');
			}
			return stringBuilder.ToString();
		}

		private static void ProcessGenericArguments(Type type, StringBuilder sb)
		{
			List<Type> list = type.GetGenericArguments().ToList();
			for (int i = 0; i < sb.Length; i++)
			{
				if (!list.Any())
				{
					break;
				}
				if (sb[i] != '`')
				{
					continue;
				}
				int num = i;
				i++;
				StringBuilder stringBuilder = new StringBuilder();
				for (; char.IsDigit(sb[i]); i++)
				{
					stringBuilder.Append(sb[i]);
				}
				string text = stringBuilder.ToString();
				int num2 = int.Parse(text);
				sb.Remove(num, text.Length + 1);
				int num3 = 1;
				num++;
				while (num3 < "</color>".Length && sb[num] == "</color>"[num3])
				{
					num3++;
					num++;
				}
				sb.Insert(num, '<');
				num++;
				int length = sb.Length;
				while (num2 > 0 && list.Any())
				{
					num2--;
					Type type2 = list.First();
					list.RemoveAt(0);
					sb.Insert(num, ProcessType(type2));
					if (num2 > 0)
					{
						num += sb.Length - length;
						sb.Insert(num, ", ");
						num += 2;
						length = sb.Length;
					}
				}
				sb.Insert(num + sb.Length - length, '>');
			}
		}

		public static string RemoveHighlighting(string _string)
		{
			if (_string == null)
			{
				throw new ArgumentNullException("_string");
			}
			_string = _string.Replace("<i>", string.Empty);
			_string = _string.Replace("</i>", string.Empty);
			_string = colorTagRegex.Replace(_string, string.Empty);
			_string = _string.Replace("</color>", string.Empty);
			return _string;
		}

		[Obsolete("Use 'ParseMethod(MethodInfo)' instead (rename).")]
		public static string HighlightMethod(MethodInfo method)
		{
			return ParseMethod(method);
		}

		public static string ParseMethod(MethodInfo method)
		{
			string key = GeneralExtensions.FullDescription((MethodBase)method);
			if (highlightedMethods.ContainsKey(key))
			{
				return highlightedMethods[key];
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(Parse(method.DeclaringType, includeNamespace: false));
			stringBuilder.Append('.');
			string text = ((!method.IsStatic) ? "#ff8000" : "#b55b02");
			stringBuilder.Append("<color=" + text + ">" + method.Name + "</color>");
			if (method.IsGenericMethod)
			{
				stringBuilder.Append("<");
				Type[] genericArguments = method.GetGenericArguments();
				for (int i = 0; i < genericArguments.Length; i++)
				{
					Type type = genericArguments[i];
					if (type.IsGenericParameter)
					{
						stringBuilder.Append("<color=#92c470>" + genericArguments[i].Name + "</color>");
					}
					else
					{
						stringBuilder.Append(Parse(type, includeNamespace: false));
					}
					if (i < genericArguments.Length - 1)
					{
						stringBuilder.Append(", ");
					}
				}
				stringBuilder.Append(">");
			}
			stringBuilder.Append('(');
			ParameterInfo[] parameters = method.GetParameters();
			for (int j = 0; j < parameters.Length; j++)
			{
				ParameterInfo parameterInfo = parameters[j];
				stringBuilder.Append(Parse(parameterInfo.ParameterType, includeNamespace: false));
				if (j < parameters.Length - 1)
				{
					stringBuilder.Append(", ");
				}
			}
			stringBuilder.Append(')');
			string text2 = stringBuilder.ToString();
			highlightedMethods.Add(key, text2);
			return text2;
		}

		[Obsolete("Use 'ParseConstructor(ConstructorInfo)' instead (rename).")]
		public static string HighlightConstructor(ConstructorInfo ctor)
		{
			return ParseConstructor(ctor);
		}

		public static string ParseConstructor(ConstructorInfo ctor)
		{
			string key = GeneralExtensions.FullDescription((MethodBase)ctor);
			if (highlightedMethods.ContainsKey(key))
			{
				return highlightedMethods[key];
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append(Parse(ctor.DeclaringType, includeNamespace: false));
			string value = stringBuilder.ToString();
			stringBuilder.Append('.');
			stringBuilder.Append(value);
			stringBuilder.Append('(');
			ParameterInfo[] parameters = ctor.GetParameters();
			for (int i = 0; i < parameters.Length; i++)
			{
				ParameterInfo parameterInfo = parameters[i];
				stringBuilder.Append(Parse(parameterInfo.ParameterType, includeNamespace: false));
				if (i < parameters.Length - 1)
				{
					stringBuilder.Append(", ");
				}
			}
			stringBuilder.Append(')');
			string text = stringBuilder.ToString();
			highlightedMethods.Add(key, text);
			return text;
		}

		public static string GetMemberInfoColor(MemberInfo memberInfo, out bool isStatic)
		{
			isStatic = false;
			if (memberInfo is FieldInfo fieldInfo)
			{
				if (fieldInfo.IsStatic)
				{
					isStatic = true;
					return "#8d8dc6";
				}
				return "#c266ff";
			}
			if (memberInfo is MethodInfo methodInfo)
			{
				if (methodInfo.IsStatic)
				{
					isStatic = true;
					return "#b55b02";
				}
				return "#ff8000";
			}
			if (memberInfo is PropertyInfo propertyInfo)
			{
				if (propertyInfo.GetAccessors(nonPublic: true)[0].IsStatic)
				{
					isStatic = true;
					return "#588075";
				}
				return "#55a38e";
			}
			if (memberInfo is ConstructorInfo)
			{
				isStatic = true;
				return "#2df7b2";
			}
			throw new NotImplementedException(memberInfo.GetType().Name + " is not supported");
		}
	}
	public static class ToStringUtility
	{
		internal static Dictionary<string, MethodInfo> toStringMethods = new Dictionary<string, MethodInfo>();

		private const string nullString = "<color=grey>null</color>";

		private const string nullUnknown = "<color=grey>null</color> (?)";

		private const string destroyedString = "<color=red>Destroyed</color>";

		private const string untitledString = "<i><color=grey>untitled</color></i>";

		private const string eventSystemNamespace = "UnityEngine.EventSystem";

		public static string PruneString(string s, int chars = 200, int lines = 5)
		{
			if (string.IsNullOrEmpty(s))
			{
				return s;
			}
			StringBuilder stringBuilder = new StringBuilder(Math.Max(chars, s.Length));
			int num = 0;
			for (int i = 0; i < s.Length; i++)
			{
				if (num >= lines || i >= chars)
				{
					stringBuilder.Append("...");
					break;
				}
				char c = s[i];
				if (c == '\r' || c == '\n')
				{
					num++;
				}
				stringBuilder.Append(c);
			}
			return stringBuilder.ToString();
		}

		public static string ToStringWithType(object value, Type fallbackType, bool includeNamespace = true)
		{
			if (value.IsNullOrDestroyed() && (object)fallbackType == null)
			{
				return "<color=grey>null</color> (?)";
			}
			Type type = value?.GetActualType() ?? fallbackType;
			string text = SignatureHighlighter.Parse(type, includeNamespace);
			StringBuilder stringBuilder = new StringBuilder();
			if (value.IsNullOrDestroyed())
			{
				if (value == null)
				{
					stringBuilder.Append("<color=grey>null</color>");
					AppendRichType(stringBuilder, text);
					return stringBuilder.ToString();
				}
				stringBuilder.Append("<color=red>Destroyed</color>");
				AppendRichType(stringBuilder, text);
				return stringBuilder.ToString();
			}
			Object val = (Object)((value is Object) ? value : null);
			if (val != null)
			{
				if (string.IsNullOrEmpty(val.name))
				{
					stringBuilder.Append("<i><color=grey>untitled</color></i>");
				}
				else
				{
					stringBuilder.Append('"');
					stringBuilder.Append(PruneString(val.name, 50, 1));
					stringBuilder.Append('"');
				}
				AppendRichType(stringBuilder, text);
			}
			else if (type.FullName.StartsWith("UnityEngine.EventSystem"))
			{
				stringBuilder.Append(text);
			}
			else
			{
				string text2 = ToString(value);
				if (type.IsGenericType || text2 == type.FullName || text2 == type.FullName + " " + type.FullName || text2 == "Il2Cpp" + type.FullName || type.FullName == "Il2Cpp" + text2)
				{
					stringBuilder.Append(text);
				}
				else
				{
					stringBuilder.Append(PruneString(text2));
					AppendRichType(stringBuilder, text);
				}
			}
			return stringBuilder.ToString();
		}

		private static void AppendRichType(StringBuilder sb, string richType)
		{
			sb.Append(' ');
			sb.Append('(');
			sb.Append(richType);
			sb.Append(')');
		}

		private static string ToString(object value)
		{
			if (value.IsNullOrDestroyed())
			{
				if (value == null)
				{
					return "<color=grey>null</color>";
				}
				return "<color=red>Destroyed</color>";
			}
			Type actualType = value.GetActualType();
			if (!toStringMethods.ContainsKey(actualType.AssemblyQualifiedName))
			{
				MethodInfo method = actualType.GetMethod("ToString", ArgumentUtility.EmptyTypes);
				toStringMethods.Add(actualType.AssemblyQualifiedName, method);
			}
			value = value.TryCast(actualType);
			string theString;
			try
			{
				theString = (string)toStringMethods[actualType.AssemblyQualifiedName].Invoke(value, ArgumentUtility.EmptyArgs);
			}
			catch (Exception e)
			{
				theString = e.ReflectionExToString();
			}
			return ReflectionUtility.ProcessTypeInString(actualType, theString);
		}
	}
	public static class UnityHelpers
	{
		private static PropertyInfo onEndEdit;

		public static bool OccuredEarlierThanDefault(this float time)
		{
			return Time.realtimeSinceStartup - 0.01f >= time;
		}

		public static bool OccuredEarlierThan(this float time, float secondsAgo)
		{
			return Time.realtimeSinceStartup - secondsAgo >= time;
		}

		public static bool IsNullOrDestroyed(this object obj, bool suppressWarning = true)
		{
			try
			{
				if (obj == null)
				{
					if (!suppressWarning)
					{
						Universe.LogWarning("The target instance is null!");
					}
					return true;
				}
				Object val = (Object)((obj is Object) ? obj : null);
				if (val != null && !Object.op_Implicit(val))
				{
					if (!suppressWarning)
					{
						Universe.LogWarning("The target UnityEngine.Object was destroyed!");
					}
					return true;
				}
				return false;
			}
			catch
			{
				return true;
			}
		}

		public static string GetTransformPath(this Transform transform, bool includeSelf = false)
		{
			StringBuilder stringBuilder = new StringBuilder();
			if (includeSelf)
			{
				stringBuilder.Append(((Object)transform).name);
			}
			while (Object.op_Implicit((Object)(object)transform.parent))
			{
				transform = transform.parent;
				stringBuilder.Insert(0, '/');
				stringBuilder.Insert(0, ((Object)transform).name);
			}
			return stringBuilder.ToString();
		}

		public static string ToHex(this Color color)
		{
			//IL_0001: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			byte b = (byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255);
			byte b2 = (byte)Mathf.Clamp(Mathf.RoundToInt(color.g * 255f), 0, 255);
			byte b3 = (byte)Mathf.Clamp(Mathf.RoundToInt(color.b * 255f), 0, 255);
			return $"{b:X2}{b2:X2}{b3:X2}";
		}

		public static Color ToColor(this string _string)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			_string = _string.Replace("#", "");
			if (_string.Length != 6)
			{
				return Color.magenta;
			}
			byte b = byte.Parse(_string.Substring(0, 2), NumberStyles.HexNumber);
			byte b2 = byte.Parse(_string.Substring(2, 2), NumberStyles.HexNumber);
			byte b3 = byte.Parse(_string.Substring(4, 2), NumberStyles.HexNumber);
			Color result = default(Color);
			result.r = (float)((decimal)b / 255m);
			result.g = (float)((decimal)b2 / 255m);
			result.b = (float)((decimal)b3 / 255m);
			result.a = 1f;
			return result;
		}

		public static UnityEvent<string> GetOnEndEdit(this InputField _this)
		{
			if ((object)onEndEdit == null)
			{
				onEndEdit = AccessTools.Property(typeof(InputField), "onEndEdit") ?? throw new Exception("Could not get InputField.onEndEdit property!");
			}
			return onEndEdit.GetValue(_this, null).TryCast<UnityEvent<string>>();
		}
	}
}
namespace UniverseLib.UI
{
	public class UIBase
	{
		internal static readonly int TOP_SORTORDER = 30000;

		public string ID { get; }

		public GameObject RootObject { get; }

		public RectTransform RootRect { get; }

		public Canvas Canvas { get; }

		public Action UpdateMethod { get; }

		public PanelManager Panels { get; }

		public bool Enabled
		{
			get
			{
				return Object.op_Implicit((Object)(object)RootObject) && RootObject.activeSelf;
			}
			set
			{
				UniversalUI.SetUIActive(ID, value);
			}
		}

		public UIBase(string id, Action updateMethod)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(id))
			{
				throw new ArgumentException("Cannot register a UI with a null or empty id!");
			}
			if (UniversalUI.registeredUIs.ContainsKey(id))
			{
				throw new ArgumentException("A UI with the id '" + id + "' is already registered!");
			}
			ID = id;
			UpdateMethod = updateMethod;
			RootObject = UIFactory.CreateUIObject(id + "_Root", UniversalUI.CanvasRoot);
			RootObject.SetActive(false);
			RootRect = RootObject.GetComponent<RectTransform>();
			Canvas = RootObject.AddComponent<Canvas>();
			Canvas.renderMode = (RenderMode)1;
			Canvas.referencePixelsPerUnit = 100f;
			Canvas.sortingOrder = TOP_SORTORDER;
			Canvas.overrideSorting = true;
			CanvasScaler val = RootObject.AddComponent<CanvasScaler>();
			val.referenceResolution = new Vector2(1920f, 1080f);
			val.screenMatchMode = (ScreenMatchMode)1;
			RootObject.AddComponent<GraphicRaycaster>();
			RectTransform component = RootObject.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.pivot = new Vector2(0.5f, 0.5f);
			Panels = CreatePanelManager();
			RootObject.SetActive(true);
			UniversalUI.registeredUIs.Add(id, this);
			UniversalUI.uiBases.Add(this);
		}

		protected virtual PanelManager CreatePanelManager()
		{
			return new PanelManager(this);
		}

		public void SetOnTop()
		{
			RootObject.transform.SetAsLastSibling();
			foreach (UIBase uiBasis in UniversalUI.uiBases)
			{
				int num = UniversalUI.CanvasRoot.transform.childCount - ((Transform)uiBasis.RootRect).GetSiblingIndex();
				uiBasis.Canvas.sortingOrder = TOP_SORTORDER - num;
			}
			UniversalUI.uiBases.Sort((UIBase a, UIBase b) => b.RootObject.transform.GetSiblingIndex().CompareTo(a.RootObject.transform.GetSiblingIndex()));
		}

		internal void Update()
		{
			try
			{
				Panels.Update();
				UpdateMethod?.Invoke();
			}
			catch (Exception arg)
			{
				Universe.LogWarning($"Exception invoking update method for {ID}: {arg}");
			}
		}
	}
	public static class UIFactory
	{
		internal static Vector2 largeElementSize = new Vector2(100f, 30f);

		internal static Vector2 smallElementSize = new Vector2(25f, 25f);

		internal static Color defaultTextColor = Color.white;

		public static GameObject CreateUIObject(string name, GameObject parent, Vector2 sizeDelta = default(Vector2))
		{
			//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)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = 5,
				hideFlags = (HideFlags)61
			};
			if (Object.op_Implicit((Object)(object)parent))
			{
				val.transform.SetParent(parent.transform, false);
			}
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = sizeDelta;
			return val;
		}

		internal static void SetDefaultTextValues(Text text)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)text).color = defaultTextColor;
			text.font = UniversalUI.DefaultFont;
			text.fontSize = 14;
		}

		internal static void SetDefaultSelectableValues(Selectable selectable)
		{
			//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)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			Navigation navigation = selectable.navigation;
			((Navigation)(ref navigation)).mode = (Mode)4;
			selectable.navigation = navigation;
			RuntimeHelper.Instance.Internal_SetColorBlock(selectable, (Color?)new Color(0.2f, 0.2f, 0.2f), (Color?)new Color(0.3f, 0.3f, 0.3f), (Color?)new Color(0.15f, 0.15f, 0.15f), (Color?)null);
		}

		public static LayoutElement SetLayoutElement(GameObject gameObject, int? minWidth = null, int? minHeight = null, int? flexibleWidth = null, int? flexibleHeight = null, int? preferredWidth = null, int? preferredHeight = null, bool? ignoreLayout = null)
		{
			LayoutElement val = gameObject.GetComponent<LayoutElement>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = gameObject.AddComponent<LayoutElement>();
			}
			if (minWidth.HasValue)
			{
				val.minWidth = minWidth.Value;
			}
			if (minHeight.HasValue)
			{
				val.minHeight = minHeight.Value;
			}
			if (flexibleWidth.HasValue)
			{
				val.flexibleWidth = flexibleWidth.Value;
			}
			if (flexibleHeight.HasValue)
			{
				val.flexibleHeight = flexibleHeight.Value;
			}
			if (preferredWidth.HasValue)
			{
				val.preferredWidth = preferredWidth.Value;
			}
			if (preferredHeight.HasValue)
			{
				val.preferredHeight = preferredHeight.Value;
			}
			if (ignoreLayout.HasValue)
			{
				val.ignoreLayout = ignoreLayout.Value;
			}
			return val;
		}

		public static T SetLayoutGroup<T>(GameObject gameObject, bool? forceWidth = null, bool? forceHeight = null, bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null, int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null) where T : HorizontalOrVerticalLayoutGroup
		{
			T val = gameObject.GetComponent<T>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = gameObject.AddComponent<T>();
			}
			return SetLayoutGroup(val, forceWidth, forceHeight, childControlWidth, childControlHeight, spacing, padTop, padBottom, padLeft, padRight, childAlignment);
		}

		public static T SetLayoutGroup<T>(T group, bool? forceWidth = null, bool? forceHeight = null, bool? childControlWidth = null, bool? childControlHeight = null, int? spacing = null, int? padTop = null, int? padBottom = null, int? padLeft = null, int? padRight = null, TextAnchor? childAlignment = null) where T : HorizontalOrVerticalLayoutGroup
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			if (forceWidth.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)group).childForceExpandWidth = forceWidth.Value;
			}
			if (forceHeight.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)group).childForceExpandHeight = forceHeight.Value;
			}
			if (childControlWidth.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)(object)group).SetChildControlWidth(childControlWidth.Value);
			}
			if (childControlHeight.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)(object)group).SetChildControlHeight(childControlHeight.Value);
			}
			if (spacing.HasValue)
			{
				((HorizontalOrVerticalLayoutGroup)group).spacing = spacing.Value;
			}
			if (padTop.HasValue)
			{
				((LayoutGroup)(object)group).padding.top = padTop.Value;
			}
			if (padBottom.HasValue)
			{
				((LayoutGroup)(object)group).padding.bottom = padBottom.Value;
			}
			if (padLeft.HasValue)
			{
				((LayoutGroup)(object)group).padding.left = padLeft.Value;
			}
			if (padRight.HasValue)
			{
				((LayoutGroup)(object)group).padding.right = padRight.Value;
			}
			if (childAlignment.HasValue)
			{
				((LayoutGroup)(object)group).childAlignment = childAlignment.Value;
			}
			return group;
		}

		public static GameObject CreatePanel(string name, GameObject parent, out GameObject contentHolder, Color? bgColor = null)
		{
			//IL_0005: 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_0061: 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_0079: 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_0096: 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_00b7: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(val, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)0, (int?)1, (int?)1, (int?)1, (int?)1, (TextAnchor?)null);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.anchoredPosition = Vector2.zero;
			component.sizeDelta = Vector2.zero;
			((Graphic)val.AddComponent<Image>()).color = Color.black;
			val.AddComponent<RectMask2D>();
			contentHolder = CreateUIObject("Content", val);
			Image val2 = contentHolder.AddComponent<Image>();
			val2.type = (Type)3;
			((Graphic)val2).color = (Color)((!bgColor.HasValue) ? new Color(0.07f, 0.07f, 0.07f) : bgColor.Value);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(contentHolder, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)3, (int?)3, (int?)3, (int?)3, (int?)3, (TextAnchor?)null);
			return val;
		}

		public static GameObject CreateVerticalGroup(GameObject parent, string name, bool forceWidth, bool forceHeight, bool childControlWidth, bool childControlHeight, int spacing = 0, Vector4 padding = default(Vector4), Color bgColor = default(Color), TextAnchor? childAlignment = null)
		{
			//IL_0005: 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_0034: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			UIFactory.SetLayoutGroup<VerticalLayoutGroup>(val, (bool?)forceWidth, (bool?)forceHeight, (bool?)childControlWidth, (bool?)childControlHeight, (int?)spacing, (int?)(int)padding.x, (int?)(int)padding.y, (int?)(int)padding.z, (int?)(int)padding.w, childAlignment);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = (Color)((bgColor == default(Color)) ? new Color(0.17f, 0.17f, 0.17f) : bgColor);
			return val;
		}

		public static GameObject CreateHorizontalGroup(GameObject parent, string name, bool forceExpandWidth, bool forceExpandHeight, bool childControlWidth, bool childControlHeight, int spacing = 0, Vector4 padding = default(Vector4), Color bgColor = default(Color), TextAnchor? childAlignment = null)
		{
			//IL_0005: 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_0034: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val, (bool?)forceExpandWidth, (bool?)forceExpandHeight, (bool?)childControlWidth, (bool?)childControlHeight, (int?)spacing, (int?)(int)padding.x, (int?)(int)padding.y, (int?)(int)padding.z, (int?)(int)padding.w, childAlignment);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = (Color)((bgColor == default(Color)) ? new Color(0.17f, 0.17f, 0.17f) : bgColor);
			return val;
		}

		public static GameObject CreateGridGroup(GameObject parent, string name, Vector2 cellSize, Vector2 spacing, Color bgColor = default(Color))
		{
			//IL_0005: 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_0022: 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_0039: 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_0043: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			GridLayoutGroup val2 = val.AddComponent<GridLayoutGroup>();
			((LayoutGroup)val2).childAlignment = (TextAnchor)0;
			val2.cellSize = cellSize;
			val2.spacing = spacing;
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = (Color)((bgColor == default(Color)) ? new Color(0.17f, 0.17f, 0.17f) : bgColor);
			return val;
		}

		public static Text CreateLabel(GameObject parent, string name, string defaultText, TextAnchor alignment = 3, Color color = default(Color), bool supportRichText = true, int fontSize = 14)
		{
			//IL_0005: 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_0029: 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_0033: 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_003b: 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)
			GameObject val = CreateUIObject(name, parent);
			Text val2 = val.AddComponent<Text>();
			SetDefaultTextValues(val2);
			val2.text = defaultText;
			((Graphic)val2).color = ((color == default(Color)) ? defaultTextColor : color);
			val2.supportRichText = supportRichText;
			val2.alignment = alignment;
			val2.fontSize = fontSize;
			return val2;
		}

		public static ButtonRef CreateButton(GameObject parent, string name, string text, Color? normalColor = null)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_002a: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			Color valueOrDefault = normalColor.GetValueOrDefault();
			if (!normalColor.HasValue)
			{
				((Color)(ref valueOrDefault))..ctor(0.25f, 0.25f, 0.25f);
				normalColor = valueOrDefault;
			}
			ButtonRef buttonRef = CreateButton(parent, name, text, default(ColorBlock));
			RuntimeHelper instance = RuntimeHelper.Instance;
			Button component = buttonRef.Component;
			Color? normal = normalColor;
			Color? val = normalColor;
			float num = 1.2f;
			Color? highlighted = (val.HasValue ? new Color?(val.GetValueOrDefault() * num) : null);
			val = normalColor;
			num = 0.7f;
			instance.Internal_SetColorBlock((Selectable)(object)component, normal, highlighted, val.HasValue ? new Color?(val.GetValueOrDefault() * num) : null);
			return buttonRef;
		}

		public static ButtonRef CreateButton(GameObject parent, string name, string text, ColorBlock colors)
		{
			//IL_0003: 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_001c: 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_0074: 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_00b4: 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)
			GameObject val = CreateUIObject(name, parent, smallElementSize);
			GameObject val2 = CreateUIObject("Text", val);
			Image val3 = val.AddComponent<Image>();
			val3.type = (Type)1;
			((Graphic)val3).color = new Color(1f, 1f, 1f, 1f);
			Button val4 = val.AddComponent<Button>();
			SetDefaultSelectableValues((Selectable)(object)val4);
			((ColorBlock)(ref colors)).colorMultiplier = 1f;
			RuntimeHelper.Instance.Internal_SetColorBlock((Selectable)(object)val4, colors);
			Text val5 = val2.AddComponent<Text>();
			val5.text = text;
			SetDefaultTextValues(val5);
			val5.alignment = (TextAnchor)4;
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			SetButtonDeselectListener(val4);
			return new ButtonRef(val4);
		}

		internal static void SetButtonDeselectListener(Button button)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			((UnityEvent)button.onClick).AddListener((UnityAction)delegate
			{
				((Selectable)button).OnDeselect((BaseEventData)null);
			});
		}

		public static GameObject CreateSlider(GameObject parent, string name, out Slider slider)
		{
			//IL_0003: 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_001c: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0058: 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_0070: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent, smallElementSize);
			GameObject val2 = CreateUIObject("Background", val);
			GameObject val3 = CreateUIObject("Fill Area", val);
			GameObject val4 = CreateUIObject("Fill", val3);
			GameObject val5 = CreateUIObject("Handle Slide Area", val);
			GameObject val6 = CreateUIObject("Handle", val5);
			Image val7 = val2.AddComponent<Image>();
			val7.type = (Type)1;
			((Graphic)val7).color = new Color(0.15f, 0.15f, 0.15f, 1f);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0.25f);
			component.anchorMax = new Vector2(1f, 0.75f);
			component.sizeDelta = new Vector2(0f, 0f);
			RectTransform component2 = val3.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0.25f);
			component2.anchorMax = new Vector2(1f, 0.75f);
			component2.anchoredPosition = new Vector2(-5f, 0f);
			component2.sizeDelta = new Vector2(-20f, 0f);
			Image val8 = val4.AddComponent<Image>();
			val8.type = (Type)1;
			((Graphic)val8).color = new Color(0.3f, 0.3f, 0.3f, 1f);
			val4.GetComponent<RectTransform>().sizeDelta = new Vector2(10f, 0f);
			RectTransform component3 = val5.GetComponent<RectTransform>();
			component3.sizeDelta = new Vector2(-20f, 0f);
			component3.anchorMin = new Vector2(0f, 0f);
			component3.anchorMax = new Vector2(1f, 1f);
			Image val9 = val6.AddComponent<Image>();
			((Graphic)val9).color = new Color(0.5f, 0.5f, 0.5f, 1f);
			val6.GetComponent<RectTransform>().sizeDelta = new Vector2(20f, 0f);
			slider = val.AddComponent<Slider>();
			slider.fillRect = val4.GetComponent<RectTransform>();
			slider.handleRect = val6.GetComponent<RectTransform>();
			((Selectable)slider).targetGraphic = (Graphic)(object)val9;
			slider.direction = (Direction)0;
			RuntimeHelper.Instance.Internal_SetColorBlock((Selectable)(object)slider, (Color?)new Color(0.4f, 0.4f, 0.4f), (Color?)new Color(0.55f, 0.55f, 0.55f), (Color?)new Color(0.3f, 0.3f, 0.3f), (Color?)null);
			return val;
		}

		public static GameObject CreateScrollbar(GameObject parent, string name, out Scrollbar scrollbar)
		{
			//IL_0003: 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_001c: 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: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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)
			//IL_00bf: 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)
			GameObject val = CreateUIObject(name, parent, smallElementSize);
			GameObject val2 = CreateUIObject("Sliding Area", val);
			GameObject val3 = CreateUIObject("Handle", val2);
			Image val4 = val.AddComponent<Image>();
			val4.type = (Type)1;
			((Graphic)val4).color = new Color(0.1f, 0.1f, 0.1f);
			Image val5 = val3.AddComponent<Image>();
			val5.type = (Type)1;
			((Graphic)val5).color = new Color(0.4f, 0.4f, 0.4f);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(-20f, -20f);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			RectTransform component2 = val3.GetComponent<RectTransform>();
			component2.sizeDelta = new Vector2(20f, 20f);
			scrollbar = val.AddComponent<Scrollbar>();
			scrollbar.handleRect = component2;
			((Selectable)scrollbar).targetGraphic = (Graphic)(object)val5;
			SetDefaultSelectableValues((Selectable)(object)scrollbar);
			return val;
		}

		public static GameObject CreateToggle(GameObject parent, string name, out Toggle toggle, out Text text, Color bgColor = default(Color), int checkWidth = 20, int checkHeight = 20)
		{
			//IL_0009: 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_009f: 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_00b3: 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_00da: 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_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: 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)
			GameObject val = CreateUIObject(name, parent, smallElementSize);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val, (bool?)false, (bool?)false, (bool?)true, (bool?)true, (int?)5, (int?)0, (int?)0, (int?)0, (int?)0, (TextAnchor?)(TextAnchor)3);
			toggle = val.AddComponent<Toggle>();
			toggle.isOn = true;
			SetDefaultSelectableValues((Selectable)(object)toggle);
			Toggle t2 = toggle;
			((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate
			{
				((Selectable)t2).OnDeselect((BaseEventData)null);
			});
			GameObject val2 = CreateUIObject("Background", val);
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).color = (Color)((bgColor == default(Color)) ? new Color(0.04f, 0.04f, 0.04f, 0.75f) : bgColor);
			UIFactory.SetLayoutGroup<HorizontalLayoutGroup>(val2, (bool?)true, (bool?)true, (bool?)true, (bool?)true, (int?)0, (int?)2, (int?)2, (int?)2, (int?)2, (TextAnchor?)null);
			SetLayoutElement(val2, checkWidth, flexibleWidth: 0, minHeight: checkHeight, flexibleHeight: 0);
			GameObject val4 = CreateUIObject("Checkmark", val2);
			Image val5 = val4.AddComponent<Image>();
			((Graphic)val5).color = new Color(0.8f, 1f, 0.8f, 0.3f);
			GameObject val6 = CreateUIObject("Label", val);
			text = val6.AddComponent<Text>();
			text.text = "";
			text.alignment = (TextAnchor)3;
			SetDefaultTextValues(text);
			SetLayoutElement(val6, 0, flexibleWidth: 0, minHeight: checkHeight, flexibleHeight: 0);
			toggle.graphic = (Graphic)(object)val5;
			((Selectable)toggle).targetGraphic = (Graphic)(object)val3;
			return val;
		}

		public static InputFieldRef CreateInputField(GameObject parent, string name, string placeHolderText)
		{
			//IL_0005: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_009b: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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_0135: 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_0156: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: 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_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject(name, parent);
			Image val2 = val.AddComponent<Image>();
			val2.type = (Type)1;
			((Graphic)val2).color = new Color(0f, 0f, 0f, 0.5f);
			InputField val3 = val.AddComponent<InputField>();
			Navigation navigation = ((Selectable)val3).navigation;
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)val3).navigation = navigation;
			val3.lineType = (LineType)0;
			((Selectable)val3).interactable = true;
			((Selectable)val3).transition = (Transition)1;
			((Selectable)val3).targetGraphic = (Graphic)(object)val2;
			RuntimeHelper.Instance.Internal_SetColorBlock((Selectable)(object)val3, (Color?)new Color(1f, 1f, 1f, 1f), (Color?)new Color(0.95f, 0.95f, 0.95f, 1f), (Color?)new Color(0.78f, 0.78f, 0.78f, 1f), (Color?)null);
			GameObject val4 = CreateUIObject("TextArea", val);
			val4.AddComponent<RectMask2D>();
			RectTransform component = val4.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			GameObject val5 = CreateUIObject("Placeholder", val4);
			Text val6 = val5.AddComponent<Text>();
			SetDefaultTextValues(val6);
			val6.text = placeHolderText ?? "...";
			((Graphic)val6).color = new Color(0.5f, 0.5f, 0.5f, 1f);
			val6.horizontalOverflow = (HorizontalWrapMode)0;
			val6.alignment = (TextAnchor)3;
			val6.fontSize = 14;
			RectTransform component2 = val5.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			val3.placeholder = (Graphic)(object)val6;
			GameObject val7 = CreateUIObject("Text", val4);
			Text val8 = val7.AddComponent<Text>();
			SetDefaultTextValues(val8);
			val8.text = "";
			((Graphic)val8).color = new Color(1f, 1f, 1f, 1f);
			val8.horizontalOverflow = (HorizontalWrapMode)0;
			val8.alignment = (TextAnchor)3;
			val8.fontSize = 14;
			RectTransform component3 = val7.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
			val3.textComponent = val8;
			val3.characterLimit = 16000;
			return new InputFieldRef(val3);
		}

		public static GameObject CreateDropdown(GameObject parent, string name, out Dropdown dropdown, string defaultItemText, int itemFontSize, Action<int> onValueChanged, string[] defaultOptions = null)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			//IL_0038: 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_004e: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing