Decompiled source of SoulOut v1.8.0

SoulOut.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Settings;
using Zorro.Settings.UI;
using Zorro.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SoulOut")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SoulOut")]
[assembly: AssemblyTitle("SoulOut")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SoulOut;

internal static class ReflectionHelper
{
	public static Type FindTypeByName(string name)
	{
		if (string.IsNullOrEmpty(name))
		{
			return null;
		}
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			Type[] types;
			try
			{
				types = assembly.GetTypes();
			}
			catch
			{
				continue;
			}
			for (int j = 0; j < types.Length; j++)
			{
				if (types[j] != null && types[j].Name == name)
				{
					return types[j];
				}
			}
		}
		return null;
	}

	public static FieldInfo FindFieldRecursive(Type t, string name, BindingFlags flags)
	{
		Type type = t;
		int num = 0;
		while (type != null && num++ < 12)
		{
			FieldInfo field = type.GetField(name, flags);
			if (field != null)
			{
				return field;
			}
			type = type.BaseType;
		}
		return null;
	}
}
[BepInPlugin("SoulOut", "SoulOut", "1.8.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ConfigEntry<KeyCode> SoulOutKey;

	internal static ConfigEntry<KeyCode> SpectateKey;

	internal static ConfigEntry<KeyCode> ReturnBodyKey;

	internal static ConfigEntry<KeyCode> WheelKey;

	internal static ConfigEntry<KeyCode> ProbeItemKey;

	internal static ConfigEntry<KeyCode> ProbeChestKey;

	internal static ConfigEntry<KeyCode> ProbePlayerKey;

	internal static ConfigEntry<KeyCode> ProbeTerrainKey;

	internal static ConfigEntry<bool> VanillaGhostVisible;

	internal static ConfigEntry<bool> WaveVisible;

	internal static ConfigEntry<bool> RippleVisible;

	internal static ConfigEntry<bool> WaveHeadVisible;

	internal static ConfigEntry<bool> WaveOutlineVisible;

	internal static ConfigEntry<int> WaveColorHead;

	internal static ConfigEntry<int> WaveColorTail;

	internal static ConfigEntry<int> WaveColorFresh;

	internal static ConfigEntry<int> WaveColorContour;

	internal static ConfigEntry<float> WaveSpeed;

	internal static ConfigEntry<float> MarkerScale;

	internal static ConfigEntry<float> MarkerPerNameCap;

	internal static ConfigEntry<float> MarkerMergeRadius;

	internal static ConfigEntry<float> MarkerVisibleDist;

	internal static ConfigEntry<bool> MarkerShowDist;

	internal static ConfigEntry<int> MarkerWashSafeColor;

	internal static ConfigEntry<int> MarkerWashSteepColor;

	internal static ConfigEntry<float> MarkerCapItem;

	internal static ConfigEntry<float> MarkerCapChest;

	internal static ConfigEntry<float> MarkerCapPlayer;

	internal static ConfigEntry<float> WaveChaseMul;

	internal static ConfigEntry<float> SfxMasterVolume;

	internal static ConfigEntry<float> ProbeItemVolume;

	internal static ConfigEntry<float> ProbeChestVolume;

	internal static ConfigEntry<float> ProbePlayerVolume;

	internal static ConfigEntry<float> GhostMoveSpeed;

	internal static ConfigEntry<float> GhostSprintMult;

	internal static ConfigEntry<float> GhostPitchLimitCfg;

	internal static ConfigEntry<float> GhostSmoothing;

	internal static ConfigEntry<bool> GhostFollowSens;

	internal static ConfigEntry<float> GhostMouseSensitivity;

	internal static ConfigEntry<float> GhostPadSensitivity;

	internal static bool GhostVisible
	{
		get
		{
			if (VanillaGhostVisible != null)
			{
				return VanillaGhostVisible.Value;
			}
			return false;
		}
	}

	private void Awake()
	{
		//IL_04be: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cf: Expected O, but got Unknown
		//IL_04e4: Expected O, but got Unknown
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fe: Expected O, but got Unknown
		ConfigFile config = ((BaseUnityPlugin)this).Config;
		VanillaGhostVisible = config.Bind<bool>("通用/General", "幽灵可见性/GhostVisibility", true, "关闭后幽灵模型对所有人隐藏(含未装Mod玩家),功能不受影响。| Hide the ghost model from everyone (incl. vanilla players) when off. Functions unaffected.");
		WaveVisible = config.Bind<bool>("通用/General", "波可见性/WaveVisibility", true, "关闭后扫描波所有视觉效果(亮环/描边/波纹)不显示,探查功能不受影响。| Hide all scan-wave visuals.");
		RippleVisible = config.Bind<bool>("通用/General", "波纹可见性/RippleVisibility", true, "单独开关地面波纹(等高线条纹);密集恐惧可关。| Toggle ground ripple stripes.");
		WaveHeadVisible = config.Bind<bool>("波/Wave", "亮环可见/WaveHead", true, "单独开关扫描亮环。| Toggle the bright scan ring.");
		WaveOutlineVisible = config.Bind<bool>("波/Wave", "描边可见/WaveOutline", true, "单独开关物体描边。| Toggle object outlines.");
		WaveColorHead = config.Bind<int>("波/Wave", "色_亮环芯/ColorHead", 46079, "亮环芯颜色 0xRRGGBB。| Head core color hex.");
		WaveColorTail = config.Bind<int>("波/Wave", "色_亮环尾/ColorTail", 3375308, "亮环尾颜色 0xRRGGBB。| Head tail color hex.");
		WaveColorFresh = config.Bind<int>("波/Wave", "色_新鲜色/ColorFresh", 46079, "描边本体颜色 0xRRGGBB。| Outline color hex.");
		WaveColorContour = config.Bind<int>("波/Wave", "色_等高线色/ColorContour", 46079, "等高线颜色 0xRRGGBB。| Contour line color hex.");
		WaveSpeed = config.Bind<float>("波/Wave", "波速/WaveSpeed", 40f, "探查波速率(米/秒)10~80,官方=40。| Scan wave rate in units/s (10~80, vanilla 40).");
		WaveChaseMul = config.Bind<float>("波/Wave", "擦波倍率/WaveChase", 2.5f, "扫尾倍率1~5:取消探查时收场缘速度=波速×倍率,1=顺着原速收、5=急收,官方=2.5。| Sweep-up speed = wave × multiplier (1~5).");
		MarkerScale = config.Bind<float>("标记/Marker", "标记尺寸/MarkerScale", 1f, "标记整体缩放倍率0.5~2,默认1;图标/文字/间距同比例,内部比例不变。| Overall marker scale multiplier.");
		MarkerPerNameCap = config.Bind<float>("标记/Marker", "同类显示数/PerNameCap", 2f, "同名物品从近到远最多标几个1~4,第N+1个起不再探。| Max markers per item type.");
		MarkerMergeRadius = config.Bind<float>("标记/Marker", "同类合并半径/MergeRadius", 6f, "同名物品间距多少米内合并为一个图标(质心)0~10;0=不合并。| Merge same-name items within this radius.");
		MarkerShowDist = config.Bind<bool>("标记/Marker", "显示距离/ShowDistance", true, "标记上方的距离行(12m)显示开关;关掉只留图标,探查逻辑完全不变。| Show distance line on markers.");
		MarkerVisibleDist = config.Bind<float>("标记/Marker", "可见距离/VisibleDist", 24f, "多少米内直接可见的物品只做表面高亮不画图标0~60;超出则一律画图标。| Within this range visible items get highlight only.");
		MarkerWashSafeColor = config.Bind<int>("标记/Marker", "地形可站色/WashSafe", 4246758, "地形探查可站坡面洗色 0xRRGGBB。| Walkable slope tint.");
		MarkerWashSteepColor = config.Bind<int>("标记/Marker", "地形陡坡色/WashSteep", 15879470, "地形探查不可站陡坡洗色 0xRRGGBB。| Steep (unwalkable) tint.");
		MarkerCapItem = config.Bind<float>("标记/Marker", "物品上限/CapItem", 15f, "物品探查最多标记簇数1~30。| Max item markers.");
		MarkerCapChest = config.Bind<float>("标记/Marker", "箱子上限/CapChest", 8f, "箱子探查最多标记数1~16。| Max chest markers.");
		MarkerCapPlayer = config.Bind<float>("标记/Marker", "玩家上限/CapPlayer", 10f, "玩家探查最多标记数1~20。| Max player markers.");
		SfxMasterVolume = config.Bind<float>("音效/Audio", "总音量/MasterVolume", 1f, "显形音效总闸0~1,与子条相乘。| Master gate 0-1 for reveal SFX.");
		ProbeItemVolume = config.Bind<float>("音效/Audio", "物品音效/ItemSfxVol", 1f, "物品图标显形音效子音量0~1。| Item reveal SFX sub-volume.");
		ProbeChestVolume = config.Bind<float>("音效/Audio", "宝箱音效/ChestSfxVol", 1f, "宝箱图标显形音效子音量0~1。| Chest reveal SFX sub-volume.");
		ProbePlayerVolume = config.Bind<float>("音效/Audio", "玩家音效/PlayerSfxVol", 1f, "玩家图标显形音效子音量0~1。| Player reveal SFX sub-volume.");
		GhostMoveSpeed = config.Bind<float>("幽灵/Ghost", "移动速度/MoveSpeed", 10f, "幽灵移动速度(0~20)。| Ghost move speed (0-20).");
		GhostSprintMult = config.Bind<float>("幽灵/Ghost", "冲刺倍率/SprintMult", 2.5f, "冲刺速度倍率(0~5)。| Sprint multiplier (0-5).");
		GhostPitchLimitCfg = config.Bind<float>("幽灵/Ghost", "俯仰限制/PitchLimit", 85f, "俯仰角度限制0~180,拉到180=解除限制可连续转圈。| Pitch limit 0-180 (180=unlimited).");
		GhostSmoothing = config.Bind<float>("幽灵/Ghost", "移动润滑度/Smoothing", 0.1f, "加减速平滑tau秒(0=跟手直切)。| Move smoothing tau (0=off).");
		GhostFollowSens = config.Bind<bool>("操作/Controls", "原版灵敏度/VanillaSensitivity", true, "跟随原版开关状态(由鼠标/控制器灵敏度行内下拉控制)。| Follow vanilla sensitivities.");
		GhostMouseSensitivity = config.Bind<float>("操作/Controls", "鼠标灵敏度/MouseSensitivity", 2f, "自定义鼠标灵敏度0.1~5(跟随关闭时生效)。| Custom mouse sensitivity (used when follow off).");
		GhostPadSensitivity = config.Bind<float>("操作/Controls", "控制器灵敏度/PadSensitivity", 2f, "自定义手柄右摇杆灵敏度0.1~5(跟随关闭时生效)。| Custom gamepad right-stick sensitivity (used when follow off).");
		SoulOutKey = config.Bind<KeyCode>("通用/General", "灵魂出窍/SoulOut", (KeyCode)103, "灵魂出窍/SoulOut。");
		WheelKey = config.Bind<KeyCode>("通用/General", "观战轮盘/SpectateWheel", (KeyCode)114, "按住打开观战轮盘,松开选定。| Hold to open the spectate wheel.");
		ProbeItemKey = config.Bind<KeyCode>("通用/General", "物品探查/ProbeItems", (KeyCode)49, "探查物品。| Probe items.");
		ProbeChestKey = config.Bind<KeyCode>("通用/General", "宝箱探查/ProbeChests", (KeyCode)50, "探查宝箱。| Probe chests.");
		ProbePlayerKey = config.Bind<KeyCode>("通用/General", "玩家探查/ProbePlayers", (KeyCode)51, "探查玩家。| Probe players.");
		ProbeTerrainKey = config.Bind<KeyCode>("通用/General", "地形探查/ProbeTerrain", (KeyCode)52, "探查地形。| Probe terrain.");
		SpectateKey = config.Bind<KeyCode>("通用/General", "观战玩家/SpectatePlayer", (KeyCode)323, "幽灵模式下对着谁按此键就观战谁。| Aim-spectate key in ghost mode.");
		ReturnBodyKey = config.Bind<KeyCode>("通用/General", "回到本体/ReturnToBody", (KeyCode)324, "幽灵模式下一键回到本体。| Return-to-body key in ghost mode.");
		try
		{
			SoulOutInputHandler.SoulScanBoot.BootAsync();
		}
		catch
		{
		}
		Harmony val = new Harmony("SoulOut");
		val.PatchAll();
		VanillaSyncBridge.TryInstall(val);
		VanillaSyncBridge.Enabled = VanillaGhostVisible.Value;
		Patch_OverheadStaminaCompat.Install(val);
		try
		{
			GhostMenuUI.Launch();
		}
		catch
		{
		}
		GameObject val2 = new GameObject("SoulOut_Input");
		Object.DontDestroyOnLoad((Object)val2);
		val2.AddComponent<SoulOutInputHandler>();
	}
}
internal static class GhostMenuUI
{
	private class WImg
	{
		public Transform t;

		public string n;

		public Color col;

		public bool act;

		public float sx = 1f;

		public float sy = 1f;

		public bool selfAct;
	}

	private class WBtn
	{
		public string tag;

		public Button b;

		public Animator an;

		public float scale;

		public string state = "";

		public List<WImg> imgs = new List<WImg>();
	}

	private class GhostBadgeTicker : MonoBehaviour
	{
		private void Update()
		{
			try
			{
				Tick();
			}
			catch
			{
			}
		}
	}

	private const float BH = 54f;

	private static float BW = 42f;

	private const float DISC_SHIFT = 16f;

	private static float? s_discOrigX;

	private const string ENTRY = "SoulOutGhostEntry";

	private static GameObject s_root;

	private static float nextTick = -1f;

	private static Sprite s_ghost;

	private static Sprite s_shadow;

	private static Rect s_ghostRect;

	private static bool s_assetsDone;

	internal static readonly HashSet<int> soulMenus = new HashSet<int>();

	private static readonly Dictionary<int, UIPage> soulSrcPages = new Dictionary<int, UIPage>();

	private static readonly Dictionary<int, UIPage> soulPages = new Dictionary<int, UIPage>();

	private static readonly HashSet<int> s_menuDefaulted = new HashSet<int>();

	private static bool s_registered;

	private static AudioClip[] s_probeClips;

	private static object s_probeSettings;

	private static object s_probeSfx;

	private static object s_sfxPlayer;

	private static MethodInfo s_playSfxMi;

	private static bool s_pipeTried;

	private static float s_lastSfxT = -99f;

	private static int s_frameBudget;

	private static int s_frameId = -1;

	private static AudioSource s_sfxSrc;

	private static string s_lastFail = "";

	private static float s_lastFailT;

	private static GameObject s_cellRoot;

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

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

	private static bool s_kcDumped;

	private static readonly List<WBtn> s_watch = new List<WBtn>();

	private static float s_badgesNextProbe = -1f;

	private static int s_badgesProbes = 0;

	internal static bool IsZh => s_isZh;

	private static bool s_isZh
	{
		get
		{
			try
			{
				FieldInfo field = typeof(LocalizedText).GetField("CURRENT_LANGUAGE", BindingFlags.Static | BindingFlags.Public);
				object obj = ((field != null) ? field.GetValue(null) : null);
				if (obj == null)
				{
					return true;
				}
				int num = (int)Convert.ChangeType(obj, typeof(int));
				return num == 9 || num == 10;
			}
			catch
			{
				return true;
			}
		}
	}

	internal static void Launch()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		if (!((Object)(object)s_root != (Object)null))
		{
			s_root = new GameObject("SoulOut_Badge");
			Object.DontDestroyOnLoad((Object)(object)s_root);
			s_root.AddComponent<GhostBadgeTicker>();
		}
	}

	private static void Tick()
	{
		float unscaledTime = Time.unscaledTime;
		if (unscaledTime < nextTick)
		{
			return;
		}
		nextTick = unscaledTime + 0.1f;
		if (!s_assetsDone && !LoadAssets())
		{
			return;
		}
		try
		{
			TryPlaceSettingsEntry();
		}
		catch
		{
		}
		try
		{
			GhostPauseEntry.Tick();
		}
		catch
		{
		}
		try
		{
			ProbeBadgesReflect();
		}
		catch
		{
		}
	}

	private static void TryPlaceSettingsEntry()
	{
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		Transform val = null;
		Transform val2 = null;
		Canvas[] array = Object.FindObjectsByType<Canvas>((FindObjectsSortMode)0);
		foreach (Canvas val3 in array)
		{
			if (!((Object)(object)val3 == (Object)null) && ((Component)val3).gameObject.activeInHierarchy)
			{
				if ((Object)(object)val == (Object)null)
				{
					val = FindDeep(((Component)val3).transform, "Button_Settings");
				}
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = FindDeep(((Component)val3).transform, "Button_Discord");
				}
				if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null)
				{
					break;
				}
			}
		}
		if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
		{
			return;
		}
		WatchBtn(val2, "DISC");
		WatchBtn(val, "SET");
		RectTransform val4 = (RectTransform)(object)((val2 is RectTransform) ? val2 : null);
		if ((Object)(object)val4 == (Object)null)
		{
			return;
		}
		if (!s_discOrigX.HasValue)
		{
			s_discOrigX = val4.anchoredPosition.x;
		}
		Vector2 anchoredPosition = val4.anchoredPosition;
		anchoredPosition.x = s_discOrigX.Value + 16f;
		val4.anchoredPosition = anchoredPosition;
		Transform parent = ((Transform)val4).parent;
		if (!((Object)(object)parent == (Object)null) && !((Object)(object)parent.Find("SoulOutGhostEntry") != (Object)null))
		{
			if ((Object)(object)SoulOutArrowFx.s_sfxHost == (Object)null)
			{
				SoulOutArrowFx.s_sfxHost = (((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null);
			}
			GameObject val5 = CloneBadge("SoulOutGhostEntry", val2, val4);
			try
			{
				CopySfxAssets(((Object)(object)val != (Object)null) ? ((Component)val).gameObject : null, val5);
			}
			catch
			{
			}
			Transform transform = val5.transform;
			ReparentTuck((RectTransform)(object)((transform is RectTransform) ? transform : null), val4, -1, 16f, -3f);
			val5.transform.localEulerAngles = new Vector3(0f, 0f, 11f);
			ShrinkAnchorRaycast(val4, left: true);
		}
	}

	private static GameObject CloneBadge(string name, Transform tmpl, RectTransform anchor, float s = 1f)
	{
		//IL_0047: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Expected O, but got Unknown
		//IL_014a: 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_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Expected O, but got Unknown
		float num = BW * s;
		float num2 = 54f * s;
		GameObject go = Object.Instantiate<GameObject>(((Component)tmpl).gameObject, (Transform)(object)anchor, false);
		((Object)go).name = name;
		Transform transform = go.transform;
		((RectTransform)((transform is RectTransform) ? transform : null)).sizeDelta = new Vector2(num, num2);
		Transform val = FindDeep(go.transform, "Panel");
		Transform val2 = FindDeep(go.transform, "PanelDrop");
		Transform val3 = FindDeep(go.transform, "Shadow");
		if ((Object)(object)val2 == (Object)null && (Object)(object)val != (Object)null && (Object)(object)val.parent != (Object)null)
		{
			val2 = MakeDropLayer(val);
		}
		SetLayer(val, s_ghost, num, num2, Vector2.zero, new Color(0.78f, 0.635f, 0.475f, 1f), killMat: false);
		if ((Object)(object)val2 != (Object)null)
		{
			SetLayer(val2, s_ghost, num, num2, new Vector2(0f, -4f), new Color(0.431f, 0.325f, 0.263f, 1f), killMat: false);
		}
		if ((Object)(object)val3 != (Object)null)
		{
			if ((Object)(object)s_shadow != (Object)null)
			{
				Rect rect = s_shadow.rect;
				SetLayer(val3, s_shadow, num * ((Rect)(ref rect)).width / ((Rect)(ref s_ghostRect)).width, num2 * ((Rect)(ref rect)).height / ((Rect)(ref s_ghostRect)).height, new Vector2(0f, -7f), new Color(0f, 0f, 0f, 0.53f), killMat: true);
			}
			else
			{
				((Component)val3).gameObject.SetActive(false);
			}
		}
		Transform[] componentsInChildren = go.GetComponentsInChildren<Transform>(true);
		foreach (Transform val4 in componentsInChildren)
		{
			string name2 = ((Object)val4).name;
			switch (name2)
			{
			default:
				if (!name2.StartsWith("SFX Appear"))
				{
					continue;
				}
				break;
			case "Border":
			case "Text":
			case "Flash":
			case "Icons":
				break;
			}
			((Component)val4).gameObject.SetActive(false);
		}
		try
		{
			CopySfxAssets(((Object)(object)anchor != (Object)null) ? ((Component)anchor).gameObject : null, go);
		}
		catch
		{
		}
		try
		{
			GameObject val5 = new GameObject("HitBox", new Type[1] { typeof(RectTransform) });
			val5.transform.SetParent(go.transform, false);
			Canvas obj2 = val5.AddComponent<Canvas>();
			Canvas componentInParent = go.GetComponentInParent<Canvas>();
			obj2.overrideSorting = true;
			obj2.sortingOrder = (((Object)(object)componentInParent != (Object)null) ? componentInParent.sortingOrder : 0) + 10;
			GameObject val6 = new GameObject("Shape", new Type[1] { typeof(RectTransform) });
			val6.transform.SetParent(val5.transform, false);
			Transform transform2 = val6.transform;
			Transform obj3 = ((transform2 is RectTransform) ? transform2 : null);
			Vector2 anchorMin = (((RectTransform)obj3).anchorMax = new Vector2(0.5f, 0.5f));
			((RectTransform)obj3).anchorMin = anchorMin;
			((RectTransform)obj3).pivot = new Vector2(0.5f, 0.5f);
			((RectTransform)obj3).sizeDelta = new Vector2(num, num2);
			((RectTransform)obj3).anchoredPosition = Vector2.zero;
			Image obj4 = val6.AddComponent<Image>();
			obj4.sprite = s_ghost;
			obj4.type = (Type)0;
			obj4.useSpriteMesh = false;
			((Graphic)obj4).color = new Color(1f, 1f, 1f, 0f);
			((Graphic)obj4).raycastTarget = true;
			obj4.alphaHitTestMinimumThreshold = 0.35f;
		}
		catch
		{
		}
		try
		{
			Animator component = go.GetComponent<Animator>();
			if ((Object)(object)component != (Object)null)
			{
				component.Rebind();
				component.Update(1f);
			}
		}
		catch
		{
		}
		Button component2 = go.GetComponent<Button>();
		if ((Object)(object)component2 != (Object)null)
		{
			Image val8 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
			if ((Object)(object)val8 != (Object)null)
			{
				((Selectable)component2).targetGraphic = (Graphic)(object)val8;
			}
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				OpenVanillaSettings(go);
			});
		}
		return go;
	}

	private static void SetLayer(Transform t, Sprite sp, float w, float h, Vector2 off, Color col, bool killMat)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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)
		if (!((Object)(object)t == (Object)null))
		{
			Image val = ((Component)t).GetComponent<Image>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)t).gameObject.AddComponent<Image>();
			}
			val.sprite = sp;
			((Graphic)val).color = col;
			val.type = (Type)0;
			val.useSpriteMesh = false;
			if (killMat)
			{
				((Graphic)val).material = null;
			}
			RectTransform val2 = (RectTransform)(object)((t is RectTransform) ? t : null);
			if ((Object)(object)val2 != (Object)null)
			{
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(0.5f, 0.5f);
				val2.anchorMax = val3;
				val2.anchorMin = val3;
				val2.pivot = new Vector2(0.5f, 0.5f);
				val2.sizeDelta = new Vector2(w, h);
				val2.anchoredPosition = off;
			}
		}
	}

	private static Transform MakeDropLayer(Transform panelT)
	{
		//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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("PanelDrop", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(panelT.parent, false);
		val.transform.SetSiblingIndex(Mathf.Max(0, panelT.GetSiblingIndex()));
		val.AddComponent<Image>();
		return val.transform;
	}

	private static void ReparentTuck(RectTransform frt, RectTransform ar, int dir, float inset, float up)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (((Object)(object)ar != (Object)null) ? ((Transform)ar).parent : null);
		if (!((Object)(object)val == (Object)null))
		{
			((Transform)frt).SetParent(val, false);
			((Transform)frt).SetSiblingIndex(Mathf.Max(0, ((Transform)ar).GetSiblingIndex()));
			frt.anchorMin = ar.anchorMin;
			frt.anchorMax = ar.anchorMax;
			frt.pivot = ar.pivot;
			float x = ar.anchoredPosition.x;
			float num = dir;
			Rect rect = ar.rect;
			frt.anchoredPosition = new Vector2(x + num * (((Rect)(ref rect)).width / 2f - inset), ar.anchoredPosition.y + up);
			if ((Object)(object)((Component)frt).GetComponent<LayoutElement>() == (Object)null)
			{
				((Component)frt).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			}
		}
	}

	private static void ShrinkAnchorRaycast(RectTransform ar, bool left)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: 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)
		Vector4 raycastPadding = (left ? new Vector4(24f, 0f, 0f, 0f) : new Vector4(0f, 0f, 24f, 0f));
		Image[] componentsInChildren = ((Component)ar).GetComponentsInChildren<Image>(true);
		foreach (Image val in componentsInChildren)
		{
			if ((Object)(object)val != (Object)null && ((Graphic)val).raycastTarget)
			{
				((Graphic)val).raycastPadding = raycastPadding;
			}
		}
	}

	private static void OpenVanillaSettings(GameObject badge)
	{
		try
		{
			OpenSoulSettings(badge);
		}
		catch
		{
		}
	}

	internal static void OpenSoulSettings(GameObject badge)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Expected O, but got Unknown
		try
		{
			EnsureRegistered();
			UIPage val = (((Object)(object)badge != (Object)null) ? badge.GetComponentInParent<UIPage>() : null);
			UIPageHandler val2 = (((Object)(object)val != (Object)null) ? val.GetPageHandler<UIPageHandler>() : null);
			if ((Object)(object)val2 == (Object)null)
			{
				LogFail("no_page_handler");
				return;
			}
			int instanceID = ((Object)val2).GetInstanceID();
			if (!soulPages.TryGetValue(instanceID, out var value) || (Object)(object)value == (Object)null)
			{
				value = BuildSoulPage(val2);
			}
			if ((Object)(object)value == (Object)null)
			{
				LogFail("no_soul_page");
				return;
			}
			val2.TransistionToPage(value, (PageTransistion)new SetActivePageTransistion());
			SharedSettingsMenu componentInChildren = ((Component)value).GetComponentInChildren<SharedSettingsMenu>(true);
			if ((Object)(object)componentInChildren != (Object)null && s_menuDefaulted.Add(((Object)componentInChildren).GetInstanceID()))
			{
				componentInChildren.ShowSettings((SettingsCategory)0);
			}
		}
		catch (Exception ex)
		{
			LogFail("open_soul " + ex);
		}
	}

	private static UIPage BuildSoulPage(UIPageHandler handler)
	{
		Component val = null;
		Type[] array = new Type[2]
		{
			typeof(MainMenuSettingsPage),
			typeof(PauseMenuSettingsMenuPage)
		};
		for (int i = 0; i < array.Length; i++)
		{
			Object[] array2 = Object.FindObjectsByType(array[i], (FindObjectsInactive)1, (FindObjectsSortMode)0);
			foreach (Object obj in array2)
			{
				Component val2 = (Component)(object)((obj is Component) ? obj : null);
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((val2 is UIPage) ? val2 : null) == (Object)null) && !((Object)(object)val2.GetComponentInParent<UIPageHandler>() != (Object)(object)handler))
				{
					val = val2;
					break;
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				break;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			return null;
		}
		GameObject val3 = Object.Instantiate<GameObject>(val.gameObject, val.transform.parent);
		((Object)val3).name = "SoulOutSettingsPage";
		SharedSettingsMenu componentInChildren = val3.GetComponentInChildren<SharedSettingsMenu>(true);
		if ((Object)(object)componentInChildren != (Object)null)
		{
			soulMenus.Add(((Object)componentInChildren).GetInstanceID());
			try
			{
				FieldInfo field = typeof(SharedSettingsMenu).GetField("m_settingsContentParent");
				Transform val4 = (Transform)((field != null) ? /*isinst with value type is only supported in some contexts*/: null);
				if ((Object)(object)val4 != (Object)null)
				{
					for (int num = val4.childCount - 1; num >= 0; num--)
					{
						Object.Destroy((Object)(object)((Component)val4.GetChild(num)).gameObject);
					}
				}
				FieldInfo field2 = typeof(SharedSettingsMenu).GetField("m_spawnedCells", BindingFlags.Instance | BindingFlags.NonPublic);
				((field2 != null) ? (field2.GetValue(componentInChildren) as IList) : null)?.Clear();
			}
			catch (Exception ex)
			{
				LogFail("clear_cells " + ex.Message);
			}
		}
		UIPage component = val3.GetComponent<UIPage>();
		if ((Object)(object)component == (Object)null)
		{
			Object.Destroy((Object)(object)val3);
			return null;
		}
		soulPages[((Object)handler).GetInstanceID()] = component;
		soulSrcPages[((Object)handler).GetInstanceID()] = val.gameObject.GetComponent<UIPage>();
		try
		{
			DressClonePage(val3);
		}
		catch (Exception ex2)
		{
			LogFail("dress_exc " + ex2.Message);
		}
		LogFail("page_cloned " + ((Object)val).name + " menu=" + ((Object)(object)componentInChildren != (Object)null));
		return component;
	}

	private static void DressClonePage(GameObject go)
	{
		bool flag = s_isZh;
		bool flag2 = false;
		StringBuilder stringBuilder = new StringBuilder();
		StringBuilder stringBuilder2 = new StringBuilder();
		TextMeshProUGUI[] componentsInChildren = go.GetComponentsInChildren<TextMeshProUGUI>(true);
		foreach (TextMeshProUGUI val in componentsInChildren)
		{
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			switch (((((TMP_Text)val).text == null) ? "" : ((TMP_Text)val).text).Trim().Replace(" ", "").ToLowerInvariant())
			{
			case "设置":
			case "settings":
			case "options":
			case "选项":
				break;
			default:
				if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((TMP_Text)val).text) && ((TMP_Text)val).text.Trim().Length <= 24)
				{
					stringBuilder.Append("[").Append(((Object)((TMP_Text)val).transform.root).name).Append("/")
						.Append(((Object)((Component)val).gameObject).name)
						.Append(":")
						.Append(((TMP_Text)val).text.Trim().Replace("\n", "/"))
						.Append("]");
				}
				continue;
			}
			((TMP_Text)val).text = (flag ? "灵魂出窍" : "SoulOut");
			LocalizedText component = ((Component)val).GetComponent<LocalizedText>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = false;
			}
			flag2 = true;
			break;
		}
		if (!flag2)
		{
			LogFail("title_miss texts=" + ((stringBuilder.Length > 2600) ? stringBuilder.ToString(0, 2600) : stringBuilder.ToString()));
		}
		LogFail("tabs order=" + stringBuilder2);
		Type type = FindType("SettingsTABSButton");
		if (type != null)
		{
			Component[] componentsInChildren2 = go.GetComponentsInChildren(type, true);
			foreach (Component val2 in componentsInChildren2)
			{
				try
				{
					object value = type.GetField("category").GetValue(val2);
					string text = ((value != null) ? value.ToString() : "");
					try
					{
						GameObject gameObject = val2.gameObject;
						stringBuilder2.Append("[").Append(((Object)gameObject).name).Append("#")
							.Append(gameObject.transform.GetSiblingIndex())
							.Append("=")
							.Append(text)
							.Append("]");
					}
					catch
					{
					}
					string text2;
					switch (text)
					{
					case "General":
						text2 = (flag ? "幽灵" : "Ghost");
						break;
					case "Graphics":
						text2 = (flag ? "操作方式" : "Controls");
						break;
					case "Audio":
						goto end_IL_0212;
					case "Controls":
						text2 = (flag ? "探查波" : "Scan Wave");
						break;
					case "Accessibility":
						text2 = (flag ? "标记" : "Markers");
						break;
					default:
					{
						GameObject gameObject2 = val2.gameObject;
						if ((Object)(object)gameObject2 != (Object)null)
						{
							gameObject2.SetActive(false);
						}
						goto end_IL_0212;
					}
					}
					TextMeshProUGUI val3 = null;
					Type baseType = type.BaseType;
					while (baseType != null && (Object)(object)val3 == (Object)null)
					{
						FieldInfo field = baseType.GetField("text", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field != null)
						{
							object? value2 = field.GetValue(val2);
							val3 = (TextMeshProUGUI)((value2 is TextMeshProUGUI) ? value2 : null);
						}
						baseType = baseType.BaseType;
					}
					if ((Object)(object)val3 == (Object)null)
					{
						val3 = val2.GetComponentInChildren<TextMeshProUGUI>(true);
					}
					if ((Object)(object)val3 != (Object)null)
					{
						((TMP_Text)val3).text = text2;
						LocalizedText component2 = ((Component)val3).GetComponent<LocalizedText>();
						if ((Object)(object)component2 != (Object)null)
						{
							((Behaviour)component2).enabled = false;
						}
					}
					end_IL_0212:;
				}
				catch
				{
				}
			}
		}
		try
		{
			Dictionary<string, RectTransform> orderTabs = new Dictionary<string, RectTransform>();
			Component[] componentsInChildren2 = go.GetComponentsInChildren(type, true);
			foreach (Component val4 in componentsInChildren2)
			{
				if (!((Object)(object)val4 == (Object)null))
				{
					object value3 = type.GetField("category").GetValue(val4);
					string text3 = ((value3 != null) ? value3.ToString() : "");
					Transform transform = val4.transform;
					RectTransform val5 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
					if ((Object)(object)val5 != (Object)null && !string.IsNullOrEmpty(text3))
					{
						orderTabs[text3] = val5;
					}
				}
			}
			Action action = delegate
			{
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_0212: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					int num = 0;
					string[] array = new string[5] { "General", "Graphics", "Controls", "Accessibility", "Audio" };
					foreach (string key in array)
					{
						if (orderTabs.TryGetValue(key, out var value4) && (Object)(object)value4 != (Object)null)
						{
							((Transform)value4).SetSiblingIndex(num++);
						}
					}
					RectTransform val8 = null;
					using (Dictionary<string, RectTransform>.Enumerator enumerator = orderTabs.GetEnumerator())
					{
						if (enumerator.MoveNext())
						{
							Transform parent = ((Transform)enumerator.Current.Value).parent;
							val8 = (RectTransform)(object)((parent is RectTransform) ? parent : null);
						}
					}
					if ((Object)(object)val8 != (Object)null)
					{
						StringBuilder stringBuilder3 = new StringBuilder();
						Component[] components = ((Component)val8).GetComponents<Component>();
						foreach (Component val9 in components)
						{
							stringBuilder3.Append(((object)val9).GetType().Name).Append(";");
						}
						for (int k = 0; k < ((Transform)val8).childCount; k++)
						{
							Transform child = ((Transform)val8).GetChild(k);
							RectTransform val10 = (RectTransform)(object)((child is RectTransform) ? child : null);
							stringBuilder3.Append(" | ").Append(((Object)child).name).Append("(a=")
								.Append(((Component)child).gameObject.activeSelf ? 1 : 0)
								.Append(",si=")
								.Append(child.GetSiblingIndex())
								.Append(",x=")
								.Append(((Object)(object)val10 != (Object)null) ? ((int)val10.anchoredPosition.x) : (-9999))
								.Append(")");
						}
						LayoutRebuilder.ForceRebuildLayoutImmediate(val8);
						stringBuilder3.Append(" >>");
						for (int l = 0; l < ((Transform)val8).childCount; l++)
						{
							Transform child2 = ((Transform)val8).GetChild(l);
							RectTransform val11 = (RectTransform)(object)((child2 is RectTransform) ? child2 : null);
							stringBuilder3.Append(" | ").Append(((Object)child2).name).Append("(x=")
								.Append(((Object)(object)val11 != (Object)null) ? ((int)val11.anchoredPosition.x) : (-9999))
								.Append(")");
						}
						try
						{
							File.AppendAllText(Path.Combine(Path.GetDirectoryName(typeof(GhostMenuUI).Assembly.Location) ?? ".", "tabs_probe.txt"), DateTime.Now.ToString("HH:mm:ss") + " " + stringBuilder3?.ToString() + Environment.NewLine);
							return;
						}
						catch
						{
							return;
						}
					}
				}
				catch
				{
				}
			};
			action();
			MonoBehaviour val6 = null;
			MonoBehaviour[] componentsInChildren3 = go.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val7 in componentsInChildren3)
			{
				if ((Object)(object)val7 != (Object)null && ((Behaviour)val7).isActiveAndEnabled)
				{
					val6 = val7;
					break;
				}
			}
			if ((Object)(object)val6 != (Object)null)
			{
				val6.StartCoroutine(DelayedTabReorder(val6, action));
			}
		}
		catch
		{
		}
	}

	private static IEnumerator DelayedTabReorder(MonoBehaviour m, Action apply)
	{
		yield return (object)new WaitForEndOfFrame();
		apply();
		yield return (object)new WaitForEndOfFrame();
		apply();
	}

	private static void EnsureRegistered()
	{
		if (s_registered)
		{
			return;
		}
		try
		{
			SettingsHandler instance = SettingsHandler.Instance;
			if (instance == null)
			{
				return;
			}
			InjectLoc("SOULOUTGHOSTVISIBLE", "可见性", "Visibility");
			InjectLoc("SOULOUTWAVEVISIBLE", "波可见性", "Wave Visible");
			InjectLoc("SOULOUTRIPPLEVISIBLE", "等高线可见性", "Contour Visible");
			InjectLoc("SOULOUTMOVESPEED", "移动速度", "Move Speed");
			InjectLoc("SOULOUTSPRINT", "冲刺倍率", "Sprint Multiplier");
			InjectLoc("SOULOUTPITCHLIM", "俯仰限制", "Pitch Limit");
			InjectLoc("SOULOUTSMOOTHING", "移动润滑度", "Move Smoothing");
			InjectLoc("SOULOUTMOUSESENS", "鼠标灵敏度", "Mouse Sensitivity");
			InjectLoc("SOULOUTPADSENS", "控制器灵敏度", "Controller Sensitivity");
			InjectLoc("SOULOUTSFXVOLUME", "总音量", "Master Volume");
			InjectLoc("SOULOUTITEMSFX", "物品音效", "Item SFX");
			InjectLoc("SOULOUTCHESTSFX", "宝箱音效", "Chest SFX");
			InjectLoc("SOULOUTPLAYERSFX", "玩家音效", "Player SFX");
			InjectLoc("SOULOUTKB1", "灵魂出窍", "Soul Out");
			InjectLoc("SOULOUTKB2", "观战轮盘", "Spectate Wheel");
			InjectLoc("SOULOUTKB3", "物品探查", "Probe Items");
			InjectLoc("SOULOUTKB4", "宝箱探查", "Probe Chests");
			InjectLoc("SOULOUTKB5", "玩家探查", "Probe Players");
			InjectLoc("SOULOUTKB6", "地形探查", "Probe Terrain");
			InjectLoc("SOULOUTKB7", "视线观战", "Aim Spectate");
			InjectLoc("SOULOUTKB8", "回到本体", "Return To Body");
			instance.AddSetting((Setting)(object)new SoulOutToggleSetting(Plugin.VanillaGhostVisible, "SOULOUTGHOSTVISIBLE", "General"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.GhostMoveSpeed, "SOULOUTMOVESPEED", 0f, 20f, 10f, "General"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.GhostSprintMult, "SOULOUTSPRINT", 0f, 5f, 2.5f, "General"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.GhostPitchLimitCfg, "SOULOUTPITCHLIM", 0f, 180f, 85f, "General"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.GhostSmoothing, "SOULOUTSMOOTHING", 0f, 1f, 0.1f, "General"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.SfxMasterVolume, "SOULOUTSFXVOLUME", 0f, 1f, 1f, "Audio"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.ProbeItemVolume, "SOULOUTITEMSFX", 0f, 1f, 1f, "Audio"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.ProbeChestVolume, "SOULOUTCHESTSFX", 0f, 1f, 1f, "Audio"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.ProbePlayerVolume, "SOULOUTPLAYERSFX", 0f, 1f, 1f, "Audio"));
			instance.AddSetting((Setting)(object)new SoulOutFollowFloatSetting(Plugin.GhostMouseSensitivity, Plugin.GhostFollowSens, "SOULOUTMOUSESENS", "Graphics", 0.1f, 5f, GhostSens, 2f));
			instance.AddSetting((Setting)(object)new SoulOutFollowFloatSetting(Plugin.GhostPadSensitivity, Plugin.GhostFollowSens, "SOULOUTPADSENS", "Graphics", 0.1f, 5f, GhostPadSens, 2f));
			InjectLoc("SOULOUTWVHEAD", "亮环可见性", "Head Ring Visible");
			InjectLoc("SOULOUTWVOUTLINE", "描边可见性", "Outline Visible");
			InjectLoc("SOULOUTWVSPEED", "探查波速率", "Scan Wave Rate");
			InjectLoc("SOULOUTWVCHASE", "扫尾倍率", "Sweep-up x");
			InjectLoc("SOULOUTMKICONSIZE", "标记尺寸", "Marker Size");
			InjectLoc("SOULOUTMKPERCAP", "同类显示数", "Per Item Type");
			InjectLoc("SOULOUTMKMERGE", "同类合并半径", "Merge Radius");
			InjectLoc("SOULOUTMKVISDIST", "可见距离", "Visible Distance");
			InjectLoc("SOULOUTMKSHOWDIST", "显示距离", "Show Distance");
			InjectLoc("SOULOUTMKWASHSAFE", "地形可站色", "Walkable Color");
			InjectLoc("SOULOUTMKWASHSTEEP", "地形陡坡色", "Steep Color");
			InjectLoc("SOULOUTMKCAPI", "物品上限", "Item Cap");
			InjectLoc("SOULOUTMKCAPC", "箱子上限", "Chest Cap");
			InjectLoc("SOULOUTMKCAPP", "玩家上限", "Player Cap");
			InjectLoc("SOULOUTWVCOLORHEAD", "亮环芯色", "Head Core Color");
			InjectLoc("SOULOUTWVCOLORTAIL", "亮环尾色", "Head Tail Color");
			InjectLoc("SOULOUTWVCOLORFRESH", "描边色", "Outline Color");
			InjectLoc("SOULOUTWVCOLORCONTOUR", "等高线色", "Contour Color");
			instance.AddSetting((Setting)(object)new SoulOutToggleSetting(Plugin.WaveVisible, "SOULOUTWAVEVISIBLE", "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutToggleSetting(Plugin.WaveHeadVisible, "SOULOUTWVHEAD", "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutToggleSetting(Plugin.WaveOutlineVisible, "SOULOUTWVOUTLINE", "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutToggleSetting(Plugin.RippleVisible, "SOULOUTRIPPLEVISIBLE", "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.WaveSpeed, "SOULOUTWVSPEED", 10f, 80f, 40f, "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.WaveChaseMul, "SOULOUTWVCHASE", 1f, 5f, 2.5f, "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutToggleSetting(Plugin.MarkerShowDist, "SOULOUTMKSHOWDIST", "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.MarkerScale, "SOULOUTMKICONSIZE", 0.5f, 2f, 1f, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.MarkerCapItem, "SOULOUTMKCAPI", 1f, 30f, 15f, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.MarkerCapChest, "SOULOUTMKCAPC", 1f, 16f, 8f, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.MarkerCapPlayer, "SOULOUTMKCAPP", 1f, 20f, 10f, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.MarkerPerNameCap, "SOULOUTMKPERCAP", 1f, 4f, 2f, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.MarkerMergeRadius, "SOULOUTMKMERGE", 0f, 10f, 6f, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutVolumeSetting(Plugin.MarkerVisibleDist, "SOULOUTMKVISDIST", 0f, 60f, 24f, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutPaletteSetting(Plugin.MarkerWashSafeColor, "SOULOUTMKWASHSAFE", "地形可站色", "Walkable Color", 4246758, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutPaletteSetting(Plugin.MarkerWashSteepColor, "SOULOUTMKWASHSTEEP", "地形陡坡色", "Steep Color", 15879470, "Accessibility"));
			instance.AddSetting((Setting)(object)new SoulOutPaletteSetting(Plugin.WaveColorHead, "SOULOUTWVCOLORHEAD", "亮环芯色", "Head Core Color", 46079, "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutPaletteSetting(Plugin.WaveColorTail, "SOULOUTWVCOLORTAIL", "亮环尾色", "Head Tail Color", 3375308, "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutPaletteSetting(Plugin.WaveColorFresh, "SOULOUTWVCOLORFRESH", "描边色", "Outline Color", 46079, "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutPaletteSetting(Plugin.WaveColorContour, "SOULOUTWVCOLORCONTOUR", "等高线色", "Contour Color", 46079, "Controls"));
			instance.AddSetting((Setting)(object)new SoulOutKeySetting(Plugin.SoulOutKey, "SOULOUTKB1", "灵魂出窍", "Soul Out", (KeyCode)103, "Graphics"));
			instance.AddSetting((Setting)(object)new SoulOutKeySetting(Plugin.WheelKey, "SOULOUTKB2", "观战轮盘", "Spectate Wheel", (KeyCode)114, "Graphics"));
			instance.AddSetting((Setting)(object)new SoulOutKeySetting(Plugin.ProbeItemKey, "SOULOUTKB3", "物品探查", "Probe Items", (KeyCode)49, "Graphics"));
			instance.AddSetting((Setting)(object)new SoulOutKeySetting(Plugin.ProbeChestKey, "SOULOUTKB4", "宝箱探查", "Probe Chests", (KeyCode)50, "Graphics"));
			instance.AddSetting((Setting)(object)new SoulOutKeySetting(Plugin.ProbePlayerKey, "SOULOUTKB5", "玩家探查", "Probe Players", (KeyCode)51, "Graphics"));
			instance.AddSetting((Setting)(object)new SoulOutKeySetting(Plugin.ProbeTerrainKey, "SOULOUTKB6", "地形探查", "Probe Terrain", (KeyCode)52, "Graphics"));
			instance.AddSetting((Setting)(object)new SoulOutKeySetting(Plugin.SpectateKey, "SOULOUTKB7", "视线观战", "Aim Spectate", (KeyCode)323, "Graphics"));
			instance.AddSetting((Setting)(object)new SoulOutKeySetting(Plugin.ReturnBodyKey, "SOULOUTKB8", "回到本体", "Return To Body", (KeyCode)324, "Graphics"));
			TryCaptureProbeClips();
			s_registered = true;
			try
			{
				StringBuilder stringBuilder = new StringBuilder("our_settings:");
				foreach (Setting allSetting in SettingsHandler.Instance.GetAllSettings())
				{
					if (allSetting is ISoulOutSetting)
					{
						string value = "?";
						string value2 = "?";
						try
						{
							value = (((object)allSetting).GetType().GetMethod("GetDisplayName")?.Invoke(allSetting, null) as string) ?? "?";
						}
						catch
						{
						}
						try
						{
							value2 = (((object)allSetting).GetType().GetMethod("GetCategory")?.Invoke(allSetting, null) as string) ?? "?";
						}
						catch
						{
						}
						stringBuilder.Append("[").Append(value).Append("=")
							.Append(value2)
							.Append("]");
					}
				}
				LogFail(stringBuilder.ToString());
			}
			catch
			{
			}
			LogFail("soul_settings_registered");
		}
		catch (Exception ex)
		{
			LogFail("reg_exc " + ex);
		}
	}

	private static void InjectLoc(string key, string zh, string en)
	{
		try
		{
			FieldInfo field = typeof(LocalizedText).GetField("MAIN_TABLE", BindingFlags.Static | BindingFlags.NonPublic);
			IDictionary dictionary = ((field != null) ? (field.GetValue(null) as IDictionary) : null);
			if (dictionary == null)
			{
				LogFail("loc_table_null");
				return;
			}
			int num = 1;
			FieldInfo field2 = typeof(LocalizedText).GetField("LANGUAGE_COUNT", BindingFlags.Static | BindingFlags.Public);
			if (field2 != null)
			{
				try
				{
					num = Mathf.Max(1, (int)field2.GetValue(null));
				}
				catch
				{
				}
			}
			List<string> list = new List<string>();
			for (int i = 0; i < num; i++)
			{
				list.Add(en);
			}
			if (num > 9)
			{
				list[9] = zh;
			}
			if (num > 10)
			{
				list[10] = zh;
			}
			dictionary[key] = list;
		}
		catch (Exception ex)
		{
			LogFail("loc_exc " + ex.Message);
		}
	}

	internal static void LogFail(string msg)
	{
		if (!(msg == s_lastFail) || !(Time.unscaledTime - s_lastFailT < 5f))
		{
			s_lastFail = msg;
			s_lastFailT = Time.unscaledTime;
		}
	}

	private static void TryCaptureProbeClips()
	{
		if (s_probeClips != null)
		{
			return;
		}
		try
		{
			Type type = FindType("SettingsUICell");
			if (type == null)
			{
				LogFail("clips_no_type");
				return;
			}
			Object[] array = Resources.FindObjectsOfTypeAll(type);
			foreach (Object obj in array)
			{
				MonoBehaviour val = (MonoBehaviour)(object)((obj is MonoBehaviour) ? obj : null);
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				FieldInfo field = type.GetField("fadeInSFX");
				object obj2 = ((field != null) ? field.GetValue(val) : null);
				if (obj2 != null)
				{
					FieldInfo field2 = obj2.GetType().GetField("clips");
					AudioClip[] array2 = ((field2 != null) ? (field2.GetValue(obj2) as AudioClip[]) : null);
					if (array2 != null && array2.Length != 0 && (Object)(object)array2[0] != (Object)null)
					{
						s_probeClips = array2;
						s_probeSfx = obj2;
						FieldInfo field3 = obj2.GetType().GetField("settings");
						s_probeSettings = ((field3 != null) ? field3.GetValue(obj2) : null);
						LogFail("clips_captured " + array2.Length + " settings=" + (s_probeSettings != null));
						return;
					}
				}
			}
			LogFail("clips_none_found");
		}
		catch (Exception ex)
		{
			LogFail("clips_exc " + ex.Message);
		}
	}

	private static bool TryInitPipeline()
	{
		if (s_pipeTried)
		{
			if (s_playSfxMi != null && s_sfxPlayer != null)
			{
				return s_probeSfx != null;
			}
			return false;
		}
		s_pipeTried = true;
		try
		{
			Type type = FindType("SFX_Player");
			if (type == null)
			{
				LogFail("pipe_no_player_type");
				return false;
			}
			FieldInfo field = type.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			s_sfxPlayer = ((field != null) ? field.GetValue(null) : null);
			MethodInfo[] methods = type.GetMethods();
			foreach (MethodInfo methodInfo in methods)
			{
				ParameterInfo[] parameters = methodInfo.GetParameters();
				if (methodInfo.Name == "PlaySFX" && parameters.Length == 6 && parameters[1].ParameterType == typeof(Vector3) && parameters[4].ParameterType == typeof(float))
				{
					s_playSfxMi = methodInfo;
					break;
				}
			}
			LogFail("pipe_init player=" + (s_sfxPlayer != null) + " mi=" + (s_playSfxMi != null));
			return s_sfxPlayer != null && s_playSfxMi != null;
		}
		catch (Exception ex)
		{
			LogFail("pipe_exc " + ex.Message);
			return false;
		}
	}

	internal static bool TryPlayProbeSfx(float catVol)
	{
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Expected O, but got Unknown
		try
		{
			int frameCount = Time.frameCount;
			if (frameCount != s_frameId)
			{
				s_frameId = frameCount;
				s_frameBudget = 3;
			}
			if (s_frameBudget <= 0)
			{
				return false;
			}
			if (s_probeClips == null)
			{
				TryCaptureProbeClips();
			}
			if (s_probeClips == null || s_probeClips.Length == 0)
			{
				return false;
			}
			float num = Mathf.Clamp01(((Plugin.SfxMasterVolume != null) ? Plugin.SfxMasterVolume.Value : 1f) * Mathf.Clamp01(catVol));
			if (num <= 0.01f)
			{
				return true;
			}
			AudioClip val = s_probeClips[Random.Range(0, s_probeClips.Length)];
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			float pitch = 1f;
			float num2 = 1f;
			try
			{
				Type st;
				if (s_probeSettings != null)
				{
					st = s_probeSettings.GetType();
					if (Time.unscaledTime - s_lastSfxT < 0.06f)
					{
						return false;
					}
					float num3 = sf("pitch_Variation", 0f);
					pitch = sf("pitch", 1f) + Random.Range((0f - num3) * 0.5f, num3 * 0.5f);
					float num4 = sf("volume_Variation", 0f);
					num2 = sf("volume", 1f) * (1f - Random.Range(0f, num4));
				}
				float sf(string n2, float d)
				{
					FieldInfo field = st.GetField(n2);
					if (!(field != null))
					{
						return d;
					}
					return (float)field.GetValue(s_probeSettings);
				}
			}
			catch
			{
			}
			s_lastSfxT = Time.unscaledTime;
			if (TryInitPipeline())
			{
				try
				{
					s_playSfxMi.Invoke(s_sfxPlayer, new object[6]
					{
						s_probeSfx,
						Vector3.zero,
						null,
						null,
						num,
						false
					});
					s_frameBudget--;
					return true;
				}
				catch
				{
				}
			}
			if ((Object)(object)s_sfxSrc == (Object)null)
			{
				GameObject val2 = new GameObject("SoulOutSfx2D");
				Object.DontDestroyOnLoad((Object)val2);
				s_sfxSrc = val2.AddComponent<AudioSource>();
				s_sfxSrc.spatialBlend = 0f;
				s_sfxSrc.playOnAwake = false;
			}
			s_sfxSrc.pitch = pitch;
			s_sfxSrc.volume = Mathf.Clamp01(num2 * num);
			s_sfxSrc.PlayOneShot(val);
			s_frameBudget--;
			return true;
		}
		catch
		{
			return false;
		}
	}

	private static void CopySfxAssets(GameObject from, GameObject to)
	{
		if ((Object)(object)from == (Object)null || (Object)(object)to == (Object)null)
		{
			return;
		}
		string[] array = new string[2] { "SFX Click", "SFX Hover" };
		foreach (string text in array)
		{
			Transform val = null;
			Transform[] componentsInChildren = ((Component)from.transform).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren)
			{
				if ((Object)(object)val2 != (Object)null && ((Object)val2).name.StartsWith(text))
				{
					val = val2;
					break;
				}
			}
			Transform val3 = FindDeep(to.transform, text);
			if ((Object)(object)val == (Object)null || (Object)(object)val3 == (Object)null)
			{
				continue;
			}
			Component[] components = ((Component)val).GetComponents<Component>();
			foreach (Component val4 in components)
			{
				if ((Object)(object)val4 == (Object)null || ((object)val4).GetType().Name != "SFX_PlayOneShot")
				{
					continue;
				}
				Component component = ((Component)val3).GetComponent(((object)val4).GetType());
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				string[] array2 = new string[2] { "sfx", "sfxs" };
				foreach (string name in array2)
				{
					FieldInfo field = ((object)val4).GetType().GetField(name);
					FieldInfo field2 = ((object)component).GetType().GetField(name);
					if (!(field == null) && !(field2 == null))
					{
						try
						{
							field2.SetValue(component, field.GetValue(val4));
						}
						catch
						{
						}
					}
				}
			}
		}
	}

	private static bool LoadAssets()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		s_assetsDone = true;
		Texture2D val = LoadTex("ghost_master.png");
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		s_ghostRect = AlphaBBox(val);
		s_ghost = Sprite.Create(val, s_ghostRect, new Vector2(0.5f, 0.5f), 100f);
		BW = 54f * ((Rect)(ref s_ghostRect)).width / ((Rect)(ref s_ghostRect)).height;
		Texture2D val2 = LoadTex("ghost_shadow.png");
		if ((Object)(object)val2 != (Object)null && ((Texture)val2).width == ((Texture)val).width && ((Texture)val2).height == ((Texture)val).height)
		{
			s_shadow = Sprite.Create(val2, AlphaBBox(val2), new Vector2(0.5f, 0.5f), 100f);
		}
		return true;
	}

	internal static GameObject MapperCell(string field)
	{
		try
		{
			Type type = FindType("InputCellMapper");
			if (type == null)
			{
				return null;
			}
			object obj = null;
			PropertyInfo property = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null)
			{
				MethodInfo getMethod = property.GetGetMethod(nonPublic: true);
				if (getMethod != null)
				{
					obj = getMethod.Invoke(null, null);
				}
			}
			if (obj == null)
			{
				Object[] array = Resources.FindObjectsOfTypeAll(type);
				int num = 0;
				if (num < array.Length)
				{
					obj = array[num];
				}
			}
			if (obj == null)
			{
				return null;
			}
			FieldInfo field2 = type.GetField(field);
			return (GameObject)((field2 != null) ? /*isinst with value type is only supported in some contexts*/: null);
		}
		catch
		{
			return null;
		}
	}

	internal static GameObject BuildPlainArrowRow(GameObject src, string key)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Expected O, but got Unknown
		//IL_0095: 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_00ad: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Expected O, but got Unknown
		try
		{
			if ((Object)(object)src == (Object)null)
			{
				return null;
			}
			if ((Object)(object)s_cellRoot == (Object)null)
			{
				s_cellRoot = new GameObject("SoulOutCellTemplates");
				s_cellRoot.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)s_cellRoot);
			}
			GameObject val = new GameObject("SoulOutRow_" + key, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(s_cellRoot.transform, false);
			Transform transform = val.transform;
			Transform obj = ((transform is RectTransform) ? transform : null);
			Transform transform2 = src.transform;
			RectTransform val2 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
			((RectTransform)obj).anchorMin = val2.anchorMin;
			((RectTransform)obj).anchorMax = val2.anchorMax;
			((RectTransform)obj).pivot = val2.pivot;
			((RectTransform)obj).anchoredPosition = val2.anchoredPosition;
			((RectTransform)obj).sizeDelta = val2.sizeDelta;
			val.AddComponent<LayoutElement>().ignoreLayout = true;
			GameObject obj2 = Object.Instantiate<GameObject>(src, val.transform);
			((Object)obj2).name = "InnerCell";
			Transform transform3 = obj2.transform;
			Transform obj3 = ((transform3 is RectTransform) ? transform3 : null);
			((RectTransform)obj3).anchorMin = Vector2.zero;
			((RectTransform)obj3).anchorMax = Vector2.one;
			((RectTransform)obj3).pivot = new Vector2(0.5f, 0.5f);
			((RectTransform)obj3).offsetMin = Vector2.zero;
			((RectTransform)obj3).offsetMax = Vector2.zero;
			val.AddComponent<SoulOutProxyInput>();
			GameObject val3 = new GameObject("DefaultBtn", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(val.transform, false);
			Image val4 = val3.AddComponent<Image>();
			((Graphic)val4).raycastTarget = true;
			Sprite val5 = SoulOutArrowFx.LoadSprite();
			if ((Object)(object)val5 != (Object)null)
			{
				val4.sprite = val5;
				((Graphic)val4).color = Color.white;
				val4.preserveAspect = true;
			}
			else
			{
				((Graphic)val4).color = new Color(0.92f, 0.88f, 0.8f, 1f);
			}
			Transform transform4 = val3.transform;
			Transform obj4 = ((transform4 is RectTransform) ? transform4 : null);
			Vector2 anchorMin = (((RectTransform)obj4).anchorMax = new Vector2(1f, 0.5f));
			((RectTransform)obj4).anchorMin = anchorMin;
			((RectTransform)obj4).pivot = new Vector2(0f, 0.5f);
			((RectTransform)obj4).anchoredPosition = new Vector2(8f, 0f);
			((RectTransform)obj4).sizeDelta = new Vector2(44f, 44f);
			Button val7 = val3.AddComponent<Button>();
			((Selectable)val7).transition = (Transition)1;
			SoulOutArrowFx.Build(val3, val7);
			LogFail("row_tpl_built " + key);
			return val;
		}
		catch (Exception ex)
		{
			LogFail("row_tpl_exc " + ex.Message);
			return null;
		}
	}

	private static void DisableVanillaInput(GameObject go, Type siType)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if (siType == null)
		{
			return;
		}
		Component[] componentsInChildren = go.GetComponentsInChildren<Component>(true);
		foreach (Component val in componentsInChildren)
		{
			if ((Object)(object)val != (Object)null && siType.IsInstanceOfType(val))
			{
				((Behaviour)(MonoBehaviour)val).enabled = false;
				break;
			}
		}
	}

	internal static GameObject BuildFollowCell(string key)
	{
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Expected O, but got Unknown
		//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0402: Unknown result type (might be due to invalid IL or missing references)
		//IL_0407: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0426: Unknown result type (might be due to invalid IL or missing references)
		//IL_0431: Unknown result type (might be due to invalid IL or missing references)
		//IL_043c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0446: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0500: Unknown result type (might be due to invalid IL or missing references)
		//IL_0505: Unknown result type (might be due to invalid IL or missing references)
		//IL_0506: Unknown result type (might be due to invalid IL or missing references)
		//IL_050d: Unknown result type (might be due to invalid IL or missing references)
		//IL_051f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0533: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Expected O, but got Unknown
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: 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_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: 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_013a: Expected O, but got Unknown
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0325: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Type type = FindType("InputCellMapper");
			if (type == null)
			{
				return null;
			}
			object obj = null;
			PropertyInfo property = type.GetProperty("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
			if (property != null)
			{
				MethodInfo getMethod = property.GetGetMethod(nonPublic: true);
				if (getMethod != null)
				{
					obj = getMethod.Invoke(null, null);
				}
			}
			if (obj == null)
			{
				Object[] array = Resources.FindObjectsOfTypeAll(type);
				int num = 0;
				if (num < array.Length)
				{
					obj = array[num];
				}
			}
			if (obj == null)
			{
				return null;
			}
			FieldInfo field = type.GetField("FloatSettingCell");
			FieldInfo field2 = type.GetField("EnumSettingCell");
			GameObject val = (GameObject)((field != null) ? /*isinst with value type is only supported in some contexts*/: null);
			GameObject val2 = (GameObject)((field2 != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				LogFail("cell_tpl missing fc=" + ((Object)(object)val != (Object)null) + " ec=" + ((Object)(object)val2 != (Object)null));
				return null;
			}
			if ((Object)(object)s_cellRoot == (Object)null)
			{
				s_cellRoot = new GameObject("SoulOutCellTemplates");
				s_cellRoot.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)s_cellRoot);
			}
			Type siType = FindType("SettingInputUICell");
			GameObject val3 = new GameObject("SoulOutFollowCell_" + key, new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(s_cellRoot.transform, false);
			Transform transform = val3.transform;
			Transform obj2 = ((transform is RectTransform) ? transform : null);
			Transform transform2 = val.transform;
			RectTransform val4 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
			((RectTransform)obj2).anchorMin = val4.anchorMin;
			((RectTransform)obj2).anchorMax = val4.anchorMax;
			((RectTransform)obj2).pivot = val4.pivot;
			((RectTransform)obj2).anchoredPosition = val4.anchoredPosition;
			((RectTransform)obj2).sizeDelta = val4.sizeDelta;
			val3.AddComponent<LayoutElement>().ignoreLayout = true;
			val3.AddComponent<SoulOutFollowInput>();
			GameObject obj3 = Object.Instantiate<GameObject>(val, val3.transform);
			((Object)obj3).name = "SliderCell";
			Transform transform3 = obj3.transform;
			Transform obj4 = ((transform3 is RectTransform) ? transform3 : null);
			((RectTransform)obj4).anchorMin = Vector2.zero;
			((RectTransform)obj4).anchorMax = Vector2.one;
			((RectTransform)obj4).pivot = new Vector2(0.5f, 0.5f);
			((RectTransform)obj4).offsetMin = Vector2.zero;
			((RectTransform)obj4).offsetMax = Vector2.zero;
			DisableVanillaInput(obj3, siType);
			GameObject obj5 = Object.Instantiate<GameObject>(val2, val3.transform);
			((Object)obj5).name = "FollowDD";
			Transform transform4 = obj5.transform;
			Transform obj6 = ((transform4 is RectTransform) ? transform4 : null);
			Vector2 anchorMin = (((RectTransform)obj6).anchorMax = new Vector2(0f, 0.5f));
			((RectTransform)obj6).anchorMin = anchorMin;
			((RectTransform)obj6).pivot = new Vector2(1f, 0.5f);
			((RectTransform)obj6).anchoredPosition = new Vector2(-8f, 0f);
			((RectTransform)obj6).sizeDelta = new Vector2(150f, 52f);
			DisableVanillaInput(obj5, siType);
			TMP_Dropdown componentInChildren = obj5.GetComponentInChildren<TMP_Dropdown>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Transform transform5 = ((Component)componentInChildren).transform;
				Transform obj7 = ((transform5 is RectTransform) ? transform5 : null);
				((RectTransform)obj7).anchorMin = Vector2.zero;
				((RectTransform)obj7).anchorMax = Vector2.one;
				((RectTransform)obj7).offsetMin = Vector2.zero;
				((RectTransform)obj7).offsetMax = Vector2.zero;
			}
			GameObject val6 = null;
			try
			{
				DumpKeyCellTree(obj, type);
			}
			catch
			{
			}
			val6 = new GameObject("DefaultBtn", new Type[1] { typeof(RectTransform) });
			val6.transform.SetParent(val3.transform, false);
			Image val7 = val6.AddComponent<Image>();
			((Graphic)val7).raycastTarget = true;
			Sprite val8 = SoulOutArrowFx.LoadSprite();
			if ((Object)(object)val8 != (Object)null)
			{
				val7.sprite = val8;
				((Graphic)val7).color = Color.white;
				val7.preserveAspect = true;
			}
			else
			{
				((Graphic)val7).color = new Color(0.92f, 0.88f, 0.8f, 1f);
				GameObject val9 = new GameObject("t", new Type[1] { typeof(RectTransform) });
				val9.transform.SetParent(val6.transform, false);
				Transform transform6 = val9.transform;
				Transform obj9 = ((transform6 is RectTransform) ? transform6 : null);
				((RectTransform)obj9).anchorMin = Vector2.zero;
				((RectTransform)obj9).anchorMax = Vector2.one;
				((RectTransform)obj9).offsetMin = Vector2.zero;
				((RectTransform)obj9).offsetMax = Vector2.zero;
				TextMeshProUGUI obj10 = val9.AddComponent<TextMeshProUGUI>();
				((TMP_Text)obj10).text = "R";
				((TMP_Text)obj10).fontSize = 26f;
				((TMP_Text)obj10).fontStyle = (FontStyles)1;
				((Graphic)obj10).color = new Color(0.15f, 0.1f, 0.05f, 1f);
				((TMP_Text)obj10).alignment = (TextAlignmentOptions)514;
				((Graphic)obj10).raycastTarget = false;
			}
			Transform transform7 = val6.transform;
			((RectTransform)((transform7 is RectTransform) ? transform7 : null)).sizeDelta = new Vector2(44f, 44f);
			Button val10 = val6.AddComponent<Button>();
			((Selectable)val10).transition = (Transition)1;
			SoulOutArrowFx.Build(val6, val10);
			((Object)val6).name = "DefaultBtn";
			Transform transform8 = val6.transform;
			Transform obj11 = ((transform8 is RectTransform) ? transform8 : null);
			anchorMin = (((RectTransform)obj11).anchorMax = new Vector2(1f, 0.5f));
			((RectTransform)obj11).anchorMin = anchorMin;
			((RectTransform)obj11).pivot = new Vector2(0f, 0.5f);
			((RectTransform)obj11).anchoredPosition = new Vector2(8f, 0f);
			LogFail("cell_tpl_built " + key);
			return val3;
		}
		catch (Exception ex)
		{
			LogFail("cell_exc " + ex.Message);
			return null;
		}
	}

	internal static float GhostSens()
	{
		try
		{
			if (Plugin.GhostFollowSens != null && Plugin.GhostFollowSens.Value)
			{
				return Mathf.Clamp(ReadVanillaSens("MouseSensitivitySetting", 2f), 0.1f, 5f);
			}
			float num = ((Plugin.GhostMouseSensitivity != null) ? Plugin.GhostMouseSensitivity.Value : 2f);
			if (num < 0.1f)
			{
				num = 2f;
			}
			return Mathf.Clamp(num, 0.1f, 5f);
		}
		catch
		{
			return 2f;
		}
	}

	internal static float GhostPadSens()
	{
		try
		{
			if (Plugin.GhostFollowSens != null && Plugin.GhostFollowSens.Value)
			{
				return Mathf.Clamp(ReadVanillaSens("ControllerSensitivitySetting", 2f), 0.1f, 5f);
			}
			float num = ((Plugin.GhostPadSensitivity != null) ? Plugin.GhostPadSensitivity.Value : 2f);
			if (num < 0.1f)
			{
				num = 2f;
			}
			return Mathf.Clamp(num, 0.1f, 5f);
		}
		catch
		{
			return 2f;
		}
	}

	internal static float ReadVanillaSens(string typeName, float fb)
	{
		try
		{
			float unscaledTime = Time.unscaledTime;
			if (s_vanillaNextT.TryGetValue(typeName, out var value) && unscaledTime < value && s_vanillaCache.TryGetValue(typeName, out var value2))
			{
				return value2;
			}
			s_vanillaNextT[typeName] = unscaledTime + 1f;
			float num = fb;
			SettingsHandler instance = SettingsHandler.Instance;
			if (instance != null)
			{
				foreach (Setting allSetting in instance.GetAllSettings())
				{
					if (allSetting != null && !(((object)allSetting).GetType().Name != typeName))
					{
						PropertyInfo property = ((object)allSetting).GetType().GetProperty("Value");
						if (property != null)
						{
							num = (float)property.GetValue(allSetting, null);
							break;
						}
					}
				}
			}
			s_vanillaCache[typeName] = num;
			return num;
		}
		catch
		{
			return fb;
		}
	}

	private static void DumpKeyCellTree(object mapperInst, Type mapperT)
	{
		//IL_019a: 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_01bf: 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)
		if (s_kcDumped)
		{
			return;
		}
		s_kcDumped = true;
		try
		{
			StringBuilder stringBuilder = new StringBuilder("mapper_fields");
			FieldInfo[] fields = mapperT.GetFields(BindingFlags.Instance | BindingFlags.Public);
			foreach (FieldInfo fieldInfo in fields)
			{
				object obj = null;
				try
				{
					obj = fieldInfo.GetValue(mapperInst);
				}
				catch
				{
				}
				string name = fieldInfo.Name;
				Object val = (Object)((obj is Object) ? obj : null);
				stringBuilder.Append(" " + name + "=" + ((val != null) ? ((val != (Object)null) ? "ok" : "null") : ((obj != null) ? "ok" : "null")));
			}
			LogFail(stringBuilder.ToString());
			FieldInfo field = mapperT.GetField("KeyCodeSettingCell");
			GameObject val2 = (GameObject)((field != null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val2 == (Object)null)
			{
				StringBuilder stringBuilder2 = new StringBuilder("sprite_cands");
				Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>();
				foreach (Sprite val3 in array)
				{
					if (!((Object)(object)val3 == (Object)null))
					{
						string text = ((Object)val3).name.ToLower();
						if (text.Contains("reset") || text.Contains("refresh") || text.Contains("reload") || text.Contains("undo") || text.Contains("clear") || text.Contains("rebind"))
						{
							string[] obj3 = new string[7]
							{
								" ",
								((Object)val3).name,
								"[",
								null,
								null,
								null,
								null
							};
							Rect rect = val3.rect;
							obj3[3] = ((int)((Rect)(ref rect)).width).ToString();
							obj3[4] = "x";
							rect = val3.rect;
							obj3[5] = ((int)((Rect)(ref rect)).height).ToString();
							obj3[6] = "]";
							stringBuilder2.Append(string.Concat(obj3));
						}
					}
				}
				LogFail(stringBuilder2.ToString());
				return;
			}
			StringBuilder sb = new StringBuilder("kc_tree");
			Action<Transform> walk = null;
			walk = delegate(Transform t)
			{
				sb.Append(" | " + ((Object)t).name + "{");
				Component[] components = ((Component)t).GetComponents<Component>();
				foreach (Component val4 in components)
				{
					if (!((Object)(object)val4 == (Object)null) && !(val4 is RectTransform) && !(val4 is CanvasRenderer))
					{
						string text2 = ((object)val4).GetType().Name;
						Image val5 = (Image)(object)((val4 is Image) ? val4 : null);
						if ((Object)(object)val5 != (Object)null && (Object)(object)val5.sprite != (Object)null)
						{
							text2 = text2 + ":" + ((Object)val5.sprite).name;
						}
						sb.Append(text2 + ",");
					}
				}
				sb.Append("}");
				for (int k = 0; k < t.childCount; k++)
				{
					walk(t.GetChild(k));
				}
			};
			walk(val2.transform);
			LogFail(sb.ToString());
		}
		catch (Exception ex)
		{
			LogFail("kc_exc " + ex.Message);
		}
	}

	internal static string FindAssetPath(string file)
	{
		try
		{
			string text = Path.GetDirectoryName(typeof(GhostMenuUI).Assembly.Location) ?? ".";
			string text2 = Path.Combine(Path.Combine(text, "ghost_assets"), file);
			if (File.Exists(text2))
			{
				return text2;
			}
			text2 = Path.Combine(text, file);
			if (File.Exists(text2))
			{
				return text2;
			}
			string[] directories = Directory.GetDirectories(text);
			for (int i = 0; i < directories.Length; i++)
			{
				text2 = Path.Combine(directories[i], file);
				if (File.Exists(text2))
				{
					return text2;
				}
			}
		}
		catch
		{
		}
		return null;
	}

	internal static Texture2D LoadTex(string file)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected O, but got Unknown
		try
		{
			string text = FindAssetPath(file);
			if (text == null)
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true);
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(text)))
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			val.Apply(true);
			((Texture)val).filterMode = (FilterMode)2;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			return val;
		}
		catch
		{
			return null;
		}
	}

	internal static Rect AlphaBBox(Texture2D t)
	{
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Color32[] pixels = t.GetPixels32();
			int num = int.MaxValue;
			int num2 = -1;
			int num3 = int.MaxValue;
			int num4 = -1;
			for (int i = 0; i < pixels.Length; i++)
			{
				if (pixels[i].a >= 8)
				{
					int num5 = i % ((Texture)t).width;
					int num6 = i / ((Texture)t).width;
					if (num5 < num)
					{
						num = num5;
					}
					if (num5 > num2)
					{
						num2 = num5;
					}
					if (num6 < num3)
					{
						num3 = num6;
					}
					if (num6 > num4)
					{
						num4 = num6;
					}
				}
			}
			if (num2 < 0)
			{
				return new Rect(0f, 0f, (float)((Texture)t).width, (float)((Texture)t).height);
			}
			return new Rect((float)num, (float)num3, (float)(num2 - num + 1), (float)(num4 - num3 + 1));
		}
		catch
		{
			return new Rect(0f, 0f, (float)((Texture)t).width, (float)((Texture)t).height);
		}
	}

	private static Type FindType(string n)
	{
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			try
			{
				Type type = assembly.GetType(n, throwOnError: false);
				if (type != null)
				{
					return type;
				}
			}
			catch
			{
			}
			try
			{
				Type[] types = assembly.GetTypes();
				foreach (Type type2 in types)
				{
					if (type2.Name == n)
					{
						return type2;
					}
				}
			}
			catch
			{
			}
		}
		return null;
	}

	private static Transform FindDeep(Transform root, string name)
	{
		if ((Object)(object)root == (Object)null)
		{
			return null;
		}
		for (int i = 0; i < root.childCount; i++)
		{
			Transform child = root.GetChild(i);
			if (((Object)child).name == name)
			{
				return child;
			}
			Transform val = FindDeep(child, name);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
		}
		return null;
	}

	private static void PLog(string s)
	{
	}

	private static void WatchBtn(Transform t, string tag)
	{
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: 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)
		foreach (WBtn item in s_watch)
		{
			if (item.tag == tag && (Object)(object)item.b != (Object)null && (Object)(object)((Component)item.b).gameObject == (Object)(object)((Component)t).gameObject)
			{
				return;
			}
		}
		Button component = ((Component)t).GetComponent<Button>();
		WBtn wBtn = new WBtn
		{
			tag = tag,
			b = component,
			an = ((Component)t).GetComponent<Animator>(),
			scale = t.localScale.x
		};
		Image[] componentsInChildren = ((Component)t).GetComponentsInChildren<Image>(true);
		foreach (Image val in componentsInChildren)
		{
			Vector3 localScale = ((Component)val).transform.localScale;
			wBtn.imgs.Add(new WImg
			{
				t = ((Component)val).transform,
				n = ((Object)val).name,
				col = ((Graphic)val).color,
				act = ((Component)val).gameObject.activeInHierarchy,
				sx = localScale.x,
				sy = localScale.y,
				selfAct = ((Component)val).gameObject.activeSelf
			});
		}
		s_watch.Add(wBtn);
		PLog("PROBE reg " + tag + " tr=" + (((Object)(object)component != (Object)null) ? ((object)((Selectable)component).transition/*cast due to .constrained prefix*/).ToString() : "nobtn") + " anim=" + ((Object)(object)wBtn.an != (Object)null) + " imgs=" + wBtn.imgs.Count);
	}

	private static void ProbeBadgesReflect()
	{
		if (s_badgesProbes >= 12)
		{
			return;
		}
		float unscaledTime = Time.unscaledTime;
		if (unscaledTime < s_badgesNextProbe)
		{
			return;
		}
		s_badgesNextProbe = unscaledTime + 5f;
		Assembly assembly = typeof(GhostMenuUI).Assembly;
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("=== wave40 PROBE#" + s_badgesProbes + " ===");
		int num = 0;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly2 in assemblies)
		{
			if (assembly2 == assembly)
			{
				continue;
			}
			Type[] types;
			try
			{
				types = assembly2.GetTypes();
			}
			catch
			{
				continue;
			}
			Type[] array = types;
			foreach (Type type in array)
			{
				if (type == null || !typeof(Component).IsAssignableFrom(type) || !Regex.IsMatch(type.Name, "badge|accolade|honor|achiev|trophy|medal", RegexOptions.IgnoreCase))
				{
					continue;
				}
				Object[] array2;
				try
				{
					array2 = Object.FindObjectsByType(type, (FindObjectsSortMode)0);
				}
				catch
				{
					continue;
				}
				Object[] array3 = array2;
				foreach (Object obj3 in array3)
				{
					Component val = (Component)(object)((obj3 is Component) ? obj3 : null);
					if (!((Object)(object)val == (Object)null) && !((Object)val.gameObject).name.StartsWith("SoulOut_"))
					{
						num++;
						stringBuilder.AppendLine("--- ROOT type=" + type.FullName + " obj=" + ((Object)val.gameObject).name + " act=" + val.gameObject.activeInHierarchy + " ---");
						DumpTree(val.transform, "", stringBuilder);
					}
				}
			}
		}
		if (num == 0)
		{
			Canvas[] array4 = Object.FindObjectsByType<Canvas>((FindObjectsSortMode)0);
			foreach (Canvas val2 in array4)
			{
				if ((Object)(object)val2 == (Object)null || !((Component)val2).gameObject.activeInHierarchy || ((Object)((Component)val2).gameObject).name.StartsWith("SoulOut_"))
				{
					continue;
				}
				string[] array5 = new string[6] { "Badge", "Accolade", "Honor", "Achievement", "Trophy", "Medal" };
				foreach (string name in array5)
				{
					Transform val3 = FindDeep(((Component)val2).transform, name);
					if ((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeInHierarchy && !((Object)((Component)val3).gameObject).name.StartsWith("SoulOut_"))
					{
						num++;
						stringBuilder.AppendLine("--- NODE canvas=" + ((Object)val2).name + " node=" + ((Object)val3).name + " ---");
						DumpTree(val3, "", stringBuilder);
						break;
					}
				}
			}
		}
		if (num == 0)
		{
			stringBuilder.AppendLine("(no badge/honor node found yet)");
		}
		PLog(stringBuilder.ToString());
		s_badgesProbes++;
	}

	private static void DumpTree(Transform tr, string ind, StringBuilder sb)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: 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_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		if (sb.Length > 50000)
		{
			sb.AppendLine("...TRUNCATED");
			return;
		}
		RectTransform val = (RectTransform)(object)((tr is RectTransform) ? tr : null);
		string text = (((Object)(object)val != (Object)null) ? (" " + val.sizeDelta.x.ToString("F1") + "x" + val.sizeDelta.y.ToString("F1")) : "");
		sb.AppendLine(ind + ((Object)tr).name + (((Component)tr).gameObject.activeSelf ? "" : " [off]") + text);
		Image component = ((Component)tr).GetComponent<Image>();
		if ((Object)(object)component != (Object)null)
		{
			string text2 = "NONE";
			if ((Object)(object)component.sprite != (Object)null)
			{
				string[] obj = new string[11]
				{
					((Object)component.sprite).name,
					" rect(",
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					null,
					null
				};
				Rect rect = component.sprite.rect;
				obj[2] = ((Rect)(ref rect)).x.ToString();
				obj[3] = ",";
				rect = component.sprite.rect;
				obj[4] = ((Rect)(ref rect)).y.ToString();
				obj[5] = ",";
				rect = component.sprite.rect;
				obj[6] = ((Rect)(ref rect)).width.ToString();
				obj[7] = ",";
				rect = component.sprite.rect;
				obj[8] = ((Rect)(ref rect)).height.ToString();
				obj[9] = ") tex=";
				obj[10] = (((Object)(object)component.sprite.texture != (Object)null) ? ((Object)component.sprite.texture).name : "?");
				text2 = string.Concat(obj);
			}
			sb.AppendLine(ind + "   IMG " + text2 + " col(" + ((Graphic)component).color.r.ToString("F2") + "," + ((Graphic)component).color.g.ToString("F2") + "," + ((Graphic)component).color.b.ToString("F2") + "," + ((Graphic)component).color.a.ToString("F2") + ") type=" + ((object)component.type/*cast due to .constrained prefix*/).ToString() + " ray=" + ((Graphic)component).raycastTarget);
		}
		Button component2 = ((Component)tr).GetComponent<Button>();
		if ((Object)(object)component2 != (Object)null)
		{
			sb.AppendLine(ind + "   BTN inter=" + ((Selectable)component2).interactable + " trans=" + ((object)((Selectable)component2).transition/*cast due to .constrained prefix*/).ToString());
		}
		if ((Object)(object)((Component)tr).GetComponent<RawImage>() != (Object)null)
		{
			sb.AppendLine(ind + "   RAWIMG");
		}
		try
		{
			TMP_Text component3 = ((Component)tr).GetComponent<TMP_Text>();
			if ((Object)(object)component3 != (Object)null && !string.IsNullOrEmpty(component3.text))
			{
				sb.AppendLine(ind + "   TXT [" + component3.text.Replace("\n", " ") + "]");
			}
		}
		catch
		{
		}
		if ((Object)(object)((Component)tr).GetComponent<Animator>() != (Object)null)
		{
			sb.AppendLine(ind + "   ANIM");
		}
		CanvasGroup component4 = ((Component)tr).GetComponent<CanvasGroup>();
		if ((Object)(object)component4 != (Object)null)
		{
			sb.AppendLine(ind + "   CG a=" + component4.alpha.ToString("F2"));
		}
		for (int i = 0; i < tr.childCount; i++)
		{
			DumpTree(tr.GetChild(i), ind + "  ", sb);
		}
	}
}
internal static class GhostPauseEntry
{
	private const string ENTRY = "SoulOutPauseGhostEntry";

	private const string ASSET = "ghost_badge.png";

	private static float s_next = -1f;

	private static Sprite s_badge;

	private static Sprite s_glow;

	private static bool s_triedTex;

	private static float s_burstUntil = -1f;

	private static readonly FieldInfo F_SETTINGS = typeof(PauseMenuMainPage).GetField("m_settingsButton", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

	internal static void Nudge()
	{
		s_burstUntil = Time.unscaledTime + 1.2f;
	}

	internal static void Prewarm()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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)
		if (!s_triedTex)
		{
			s_triedTex = true;
			Texture2D val = GhostMenuUI.LoadTex("ghost_badge.png");
			if ((Object)(object)val != (Object)null)
			{
				Rect val2 = GhostMenuUI.AlphaBBox(val);
				s_badge = Sprite.Create(val, val2, new Vector2(0.5f, 0.5f), 100f);
			}
			Texture2D val3 = GhostMenuUI.LoadTex("ghost_glow.png");
			if ((Object)(object)val3 != (Object)null)
			{
				Rect val4 = GhostMenuUI.AlphaBBox(val3);
				s_glow = Sprite.Create(val3, val4, new Vector2(0.5f, 0.5f), 100f);
			}
		}
	}

	internal static void Tick()
	{
		float unscaledTime = Time.unscaledTime;
		if (unscaledTime < s_next)
		{
			return;
		}
		s_next = unscaledTime + ((unscaledTime < s_burstUntil) ? 0.02f : 0.2f);
		try
		{
			TryBuild();
		}
		catch
		{
		}
	}

	private static void TryBuild()
	{
		//IL_0510: Unknown result type (might be due to invalid IL or missing references)
		//IL_051a: Expected O, but got Unknown
		//IL_0091: 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_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_041e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0444: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		PauseMenuMainPage val = null;
		Button val2 = null;
		PauseMenuMainPage[] array = Object.FindObjectsByType<PauseMenuMainPage>((FindObjectsSortMode)0);
		foreach (PauseMenuMainPage val3 in array)
		{
			if (!((Object)(object)val3 == (Object)null))
			{
				val2 = ReadSettingsButton(val3);
				if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)val2).gameObject != (Object)null)
				{
					val = val3;
					break;
				}
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		GameObject gameObject = ((Component)val2).gameObject;
		Transform transform = gameObject.transform;
		RectTransform val4 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
		Transform val5 = (((Object)(object)val4 != (Object)null) ? ((Transform)val4).parent : null);
		if ((Object)(object)val5 == (Object)null)
		{
			return;
		}
		Rect rect = val4.rect;
		if (((Rect)(ref rect)).height < 1f || (Object)(object)val5.Find("SoulOutPauseGhostEntry") != (Object)null)
		{
			return;
		}
		if (!s_triedTex)
		{
			s_triedTex = true;
			Texture2D val6 = GhostMenuUI.LoadTex("ghost_badge.png");
			if ((Object)(object)val6 != (Object)null)
			{
				Rect val7 = GhostMenuUI.AlphaBBox(val6);
				s_badge = Sprite.Create(val6, val7, new Vector2(0.5f, 0.5f), 100f);
			}
			Texture2D val8 = GhostMenuUI.LoadTex("ghost_glow.png");
			if ((Object)(object)val8 != (Object)null)
			{
				Rect val9 = GhostMenuUI.AlphaBBox(val8);
				s_glow = Sprite.Create(val8, val9, new Vector2(0.5f, 0.5f), 100f);
			}
		}
		if ((Object)(object)s_badge == (Object)null)
		{
			return;
		}
		GameObject val10 = Object.Instantiate<GameObject>(gameObject, val5, false);
		((Object)val10).name = "SoulOutPauseGhostEntry";
		Transform transform2 = val10.transform;
		RectTransform val11 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
		rect = val4.rect;
		float num = ((Rect)(ref rect)).height * 0.54f;
		if (num <= 0f)
		{
			num = 44f;
		}
		Vector2 val12 = default(Vector2);
		((Vector2)(ref val12))..ctor(0.5f, 0.5f);
		val11.anchorMax = val12;
		val11.anchorMin = val12;
		val11.pivot = new Vector2(0.5f, 0.5f);
		val11.sizeDelta = new Vector2(num, num);
		val11.anchoredPosition = Vector2.zero;
		Vector3[] array2 = (Vector3[])(object)new Vector3[4];
		val4.GetWorldCorners(array2);
		Vector3 val13 = (array2[0] + array2[2]) * 0.5f;
		rect = val4.rect;
		Vector3 position = val13 + ((Transform)val4).TransformVector(new Vector3(((Rect)(ref rect)).width * 0.27f, 0f, 0f));
		((Transform)val11).position = position;
		((Transform)val11).SetSiblingIndex(((Transform)val4).GetSiblingIndex() + 1);
		if ((Object)(object)((Component)val11).GetComponent<LayoutElement>() == (Object)null)
		{
			((Component)val11).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
		}
		Button component = val10.GetComponent<Button>();
		Image val14 = (Image)(((Object)(object)component != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
		if ((Object)(object)val14 == (Object)null)
		{
			val14 = val10.GetComponent<Image>();
		}
		if ((Object)(object)val14 != (Object)null)
		{
			val14.sprite = s_badge;
			val14.type = (Type)0;
			val14.useSpriteMesh = false;
			val14.preserveAspect = true;
			((Graphic)val14).color = Color.white;
			((Graphic)val14).raycastTarget = true;
			val14.alphaHitTestMinimumThreshold = 0.5f;
		}
		Transform[] componentsInChildren = val10.GetComponentsInChildren<Transform>(true);
		foreach (Transform val15 in componentsInChildren)
		{
			if ((Object)(object)val14 != (Object)null && (Object)(object)((Component)val15).gameObject == (Object)(object)((Component)val14).gameObject)
			{
				continue;
			}
			string text = (((Object)((Component)val15).gameObject).name ?? "").ToLowerInvariant();
			bool flag = text.Contains("