Decompiled source of Core v1.0.11

BepInEx/plugins/smolMods.Core.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using Mirror;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("smolMods.Core")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e90a00273091d71235f09886429f05ccd89d5c5b")]
[assembly: AssemblyProduct("smolMods.Core")]
[assembly: AssemblyTitle("smolMods.Core")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SmolMods.Core
{
	internal static class CharacterPreview
	{
		private class Entry
		{
			public GameObject root;

			public Image head;

			public Image tuft;

			public Image chest;

			public Image handL;

			public Image handR;

			public Image body;

			public Image footL;

			public Image footR;

			public Image armL;

			public Image armR;

			public Image legL;

			public Image legR;

			public TextMeshProUGUI mood;
		}

		private static readonly List<Entry> Entries = new List<Entry>();

		private static Sprite _circle;

		private static float _nextTick;

		private static readonly Color FallbackHead = new Color(0.18f, 0.62f, 0.39f);

		private static readonly Color FallbackTorso = new Color(0.94f, 0.23f, 0.16f);

		private static readonly Color FallbackLegs = new Color(0.165f, 0.165f, 0.18f);

		private static readonly Color EyeInk = new Color(1f, 0.98f, 0.92f);

		private static readonly Color MoodInkColor = new Color(0.13f, 0.11f, 0.09f);

		private static Sprite _arc;

		internal static void BuildPanel(ModPanelContext ctx)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Expected O, but got Unknown
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_0514: Expected O, but got Unknown
			try
			{
				Entry entry = new Entry();
				GameObject val = (entry.root = new GameObject("ModsCharacterPreview"));
				val.transform.SetParent(ctx.NoteGo.transform.parent, false);
				RectTransform component = ctx.NoteGo.GetComponent<RectTransform>();
				RectTransform val2 = val.AddComponent<RectTransform>();
				Vector2 val3 = ctx.NextSlot(new Vector2(340f, 340f), -110f);
				if ((Object)(object)component != (Object)null)
				{
					val2.anchorMin = component.anchorMin;
					val2.anchorMax = component.anchorMax;
					val2.pivot = component.pivot;
					val2.anchoredPosition = component.anchoredPosition + val3;
				}
				val2.sizeDelta = new Vector2(340f, 340f);
				entry.legL = AddArc(val, "leg_l", new Vector2(-24f, -107f), new Vector2(76f, 48f), 90f, FallbackLegs);
				entry.legR = AddArc(val, "leg_r", new Vector2(24f, -107f), new Vector2(76f, 48f), -90f, FallbackLegs);
				entry.body = AddPart(val, "body", new Vector2(0f, -35f), new Vector2(116f, 116f), FallbackLegs, circle: true);
				entry.footL = AddPart(val, "foot_l", new Vector2(-31f, -138f), new Vector2(41f, 15f), FallbackLegs, circle: true);
				entry.footR = AddPart(val, "foot_r", new Vector2(31f, -138f), new Vector2(41f, 15f), FallbackLegs, circle: true);
				((Transform)((Graphic)entry.footL).rectTransform).localEulerAngles = new Vector3(0f, 0f, 10f);
				((Transform)((Graphic)entry.footR).rectTransform).localEulerAngles = new Vector3(0f, 0f, -10f);
				entry.armL = AddArc(val, "arm_l", new Vector2(-62f, 30f), new Vector2(120f, 60f), 15f, FallbackTorso);
				entry.armR = AddArc(val, "arm_r", new Vector2(62f, 30f), new Vector2(120f, 60f), -15f, FallbackTorso);
				entry.chest = AddPart(val, "chest", new Vector2(0f, 40f), new Vector2(64f, 64f), FallbackTorso, circle: true);
				entry.handL = AddPart(val, "hand_l", new Vector2(-96f, 25f), new Vector2(32f, 32f), FallbackTorso, circle: true);
				entry.handR = AddPart(val, "hand_r", new Vector2(96f, 25f), new Vector2(32f, 32f), FallbackTorso, circle: true);
				entry.tuft = AddPart(val, "tuft", new Vector2(-38f, 140f), new Vector2(42f, 20f), FallbackHead, circle: true);
				((Transform)((Graphic)entry.tuft).rectTransform).localEulerAngles = new Vector3(0f, 0f, -40f);
				entry.head = AddPart(val, "head", new Vector2(0f, 100f), new Vector2(88f, 88f), FallbackHead, circle: true);
				AddPart(val, "eye", new Vector2(0f, 102f), new Vector2(58f, 58f), EyeInk, circle: true);
				GameObject val4 = new GameObject("mood");
				val4.transform.SetParent(val.transform, false);
				RectTransform obj = val4.AddComponent<RectTransform>();
				obj.anchoredPosition = new Vector2(0f, 102f);
				obj.sizeDelta = new Vector2(70f, 50f);
				entry.mood = val4.AddComponent<TextMeshProUGUI>();
				((TMP_Text)entry.mood).alignment = (TextAlignmentOptions)514;
				((TMP_Text)entry.mood).enableWordWrapping = false;
				((TMP_Text)entry.mood).overflowMode = (TextOverflowModes)0;
				((Graphic)entry.mood).raycastTarget = false;
				((TMP_Text)entry.mood).fontSize = 40f;
				((Graphic)entry.mood).color = MoodInkColor;
				((TMP_Text)entry.mood).text = "";
				if ((Object)(object)ModSettingsApi.MenuGlyphFont != (Object)null)
				{
					((TMP_Text)entry.mood).font = ModSettingsApi.MenuGlyphFont;
				}
				ModSettingsApi.RegisterColorRoot(val.transform);
				ctx.RegisterPanel(val);
				Entries.Add(entry);
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					log.LogInfo((object)"Character preview created");
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = ModSettingsApi.Log;
				if (log2 != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Character preview creation failed: ");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message);
					}
					log2.LogWarning(val5);
				}
			}
		}

		private static Image AddArc(GameObject root, string name, Vector2 pos, Vector2 size, float rotZ, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(root.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchoredPosition = pos;
			obj.sizeDelta = size;
			((Transform)obj).localEulerAngles = new Vector3(0f, 0f, rotZ);
			Image obj2 = val.AddComponent<Image>();
			((Graphic)obj2).raycastTarget = false;
			obj2.sprite = ArcSprite();
			((Graphic)obj2).color = color;
			return obj2;
		}

		private static Sprite ArcSprite()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_arc != (Object)null)
			{
				return _arc;
			}
			Texture2D val = new Texture2D(96, 96, (TextureFormat)5, false);
			((Object)val).hideFlags = (HideFlags)61;
			float num = 47.5f;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(num + 32f * Mathf.Cos((float)Math.PI / 6f), num + 32f * Mathf.Sin((float)Math.PI / 6f));
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(num + 32f * Mathf.Cos(2.6179938f), num + 32f * Mathf.Sin(2.6179938f));
			Vector2 val4 = default(Vector2);
			for (int i = 0; i < 96; i++)
			{
				for (int j = 0; j < 96; j++)
				{
					float num2 = (float)j - num;
					float num3 = (float)i - num;
					float num4 = Mathf.Atan2(num3, num2);
					float num6;
					if (num4 >= (float)Math.PI / 6f && num4 <= 2.6179938f)
					{
						float num5 = Mathf.Sqrt(num2 * num2 + num3 * num3);
						num6 = Mathf.Clamp01(5.5f - Mathf.Abs(num5 - 32f) + 0.5f);
					}
					else
					{
						((Vector2)(ref val4))..ctor((float)j, (float)i);
						float num7 = Mathf.Min(Vector2.Distance(val4, val2), Vector2.Distance(val4, val3));
						num6 = Mathf.Clamp01(5.5f - num7 + 0.5f);
					}
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num6));
				}
			}
			val.Apply();
			_arc = Sprite.Create(val, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f));
			((Object)_arc).hideFlags = (HideFlags)61;
			return _arc;
		}

		private static Image AddPart(GameObject root, string name, Vector2 pos, Vector2 size, Color color, bool circle)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(root.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchoredPosition = pos;
			obj.sizeDelta = size;
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).raycastTarget = false;
			if (circle)
			{
				val2.sprite = CircleSprite();
			}
			((Graphic)val2).color = color;
			return val2;
		}

		private static Sprite CircleSprite()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_circle != (Object)null)
			{
				return _circle;
			}
			Texture2D val = new Texture2D(96, 96, (TextureFormat)5, false);
			((Object)val).hideFlags = (HideFlags)61;
			float num = 46.5f;
			float num2 = 47.5f;
			for (int i = 0; i < 96; i++)
			{
				for (int j = 0; j < 96; j++)
				{
					float num3 = Mathf.Sqrt(((float)j - num2) * ((float)j - num2) + ((float)i - num2) * ((float)i - num2));
					float num4 = Mathf.Clamp01(num - num3 + 0.5f);
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num4));
				}
			}
			val.Apply();
			_circle = Sprite.Create(val, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f));
			((Object)_circle).hideFlags = (HideFlags)61;
			return _circle;
		}

		internal static void Tick()
		{
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: 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_00ce: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_00f7: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime < _nextTick)
			{
				return;
			}
			_nextTick = Time.unscaledTime + 0.1f;
			try
			{
				bool flag = false;
				for (int num = Entries.Count - 1; num >= 0; num--)
				{
					if ((Object)(object)Entries[num].root == (Object)null)
					{
						Entries.RemoveAt(num);
					}
					else if (Entries[num].root.activeInHierarchy)
					{
						flag = true;
					}
				}
				if (!flag)
				{
					return;
				}
				int head;
				int torso;
				int legs;
				bool inWalk = PlayerPalette.TryGetActualLook(out head, out torso, out legs);
				PreviewLook previewLook = ((ModSettingsApi.PreviewLookProvider != null) ? ModSettingsApi.PreviewLookProvider() : new PreviewLook
				{
					Head = -1,
					Torso = -1,
					Legs = -1
				});
				Color c = PartColor(inWalk, head, previewLook.Head, FallbackHead);
				Color c2 = PartColor(inWalk, torso, previewLook.Torso, FallbackTorso);
				Color c3 = PartColor(inWalk, legs, previewLook.Legs, FallbackLegs);
				string text = "";
				if (ModSettingsApi.PreviewGlyphProvider != null)
				{
					try
					{
						text = ModSettingsApi.PreviewGlyphProvider() ?? "";
					}
					catch
					{
						text = "";
					}
				}
				foreach (Entry entry in Entries)
				{
					if (!((Object)(object)entry.root == (Object)null) && entry.root.activeInHierarchy)
					{
						Tint(entry.head, c);
						Tint(entry.tuft, c);
						Tint(entry.chest, c2);
						Tint(entry.handL, c2);
						Tint(entry.handR, c2);
						Tint(entry.armL, c2);
						Tint(entry.armR, c2);
						Tint(entry.body, c3);
						Tint(entry.footL, c3);
						Tint(entry.footR, c3);
						Tint(entry.legL, c3);
						Tint(entry.legR, c3);
						if ((Object)(object)entry.mood != (Object)null && ((TMP_Text)entry.mood).text != text)
						{
							((TMP_Text)entry.mood).text = text;
						}
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag2 = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Character preview tick failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val);
				}
			}
		}

		private static void Tint(Image img, Color c)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)img != (Object)null && ((Graphic)img).color != c)
			{
				((Graphic)img).color = c;
			}
		}

		private static Color PartColor(bool inWalk, int actualId, int rowValue, Color fallback)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Color? val = PlayerPalette.PaletteDisplayColor(rowValue);
			if (!val.HasValue && inWalk)
			{
				val = PlayerPalette.PaletteDisplayColor(actualId);
			}
			return val ?? fallback;
		}
	}
	public static class HudTintApi
	{
		public static readonly Color DefaultDarkIcon = new Color(0.13f, 0.13f, 0.15f);

		private static readonly Dictionary<int, (Graphic g, Color c)> HudGraphics = new Dictionary<int, (Graphic, Color)>();

		private static readonly Dictionary<int, (Renderer r, string prop, Color c)> HudRenderers = new Dictionary<int, (Renderer, string, Color)>();

		private static readonly Dictionary<int, (SpriteRenderer r, Color c)> HudSprites = new Dictionary<int, (SpriteRenderer, Color)>();

		private static string _activeId;

		private static Func<Color?> _activeTint;

		private static Action _activePreempted;

		private static bool _arbitrating;

		private static readonly Dictionary<int, bool> StaticHudVerdict = new Dictionary<int, bool>();

		private static float _nextTick;

		private static readonly string[] ColorPropsFallback = new string[3] { "_BaseColor", "_Color", "_TintColor" };

		private static readonly Dictionary<int, string[]> ShaderColorProps = new Dictionary<int, string[]>();

		private static MaterialPropertyBlock _mpb;

		public static void Claim(string claimantId, Func<Color?> tint, Action onPreempted)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			if (string.IsNullOrEmpty(claimantId) || _arbitrating)
			{
				return;
			}
			try
			{
				_arbitrating = true;
				if (_activeId != null && _activeId != claimantId)
				{
					Action activePreempted = _activePreempted;
					try
					{
						activePreempted?.Invoke();
					}
					catch (Exception ex)
					{
						ManualLogSource log = ModSettingsApi.Log;
						if (log != null)
						{
							bool flag = default(bool);
							BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral("HUD preempt handler failed: ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
							}
							log.LogWarning(val);
						}
					}
				}
				_activeId = claimantId;
				_activeTint = tint;
				_activePreempted = onPreempted;
				RestoreHud();
				ApplyHud();
			}
			finally
			{
				_arbitrating = false;
			}
		}

		public static void Release(string claimantId)
		{
			if (_activeId != null && !(_activeId != claimantId))
			{
				_activeId = null;
				_activeTint = null;
				_activePreempted = null;
				RestoreHud();
			}
		}

		public static bool IsClaimed(string claimantId)
		{
			return _activeId == claimantId;
		}

		public static bool IsHudOwned(Graphic g)
		{
			if ((Object)(object)g == (Object)null)
			{
				return false;
			}
			int instanceID = ((Object)g).GetInstanceID();
			if (HudGraphics.ContainsKey(instanceID))
			{
				return true;
			}
			if (StaticHudVerdict.TryGetValue(instanceID, out var value))
			{
				return value;
			}
			value = false;
			try
			{
				Transform val = ((Component)g).transform;
				while ((Object)(object)val != (Object)null)
				{
					string name = ((Object)val).name;
					if (!string.IsNullOrEmpty(name))
					{
						if ((Object)(object)((Component)val).GetComponent<SettingsRow>() != (Object)null || (Object)(object)((Component)val).GetComponent<SettingsMenu>() != (Object)null)
						{
							break;
						}
						name = name.ToLowerInvariant();
						if (name.Contains("crosshair") || name.Contains("armhud") || name.Contains("reticle"))
						{
							value = true;
							break;
						}
					}
					val = val.parent;
				}
			}
			catch
			{
			}
			StaticHudVerdict[instanceID] = value;
			return value;
		}

		internal static void Tick()
		{
			if (_activeId == null || Time.unscaledTime < _nextTick)
			{
				return;
			}
			_nextTick = Time.unscaledTime + 0.2f;
			try
			{
				ApplyHud();
			}
			catch
			{
			}
		}

		private static Color CurrentTint()
		{
			//IL_002a: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (_activeTint != null)
			{
				try
				{
					Color? val = _activeTint();
					if (val.HasValue)
					{
						return val.Value;
					}
				}
				catch
				{
				}
			}
			return DefaultDarkIcon;
		}

		private static IEnumerable<Transform> CrosshairRoots()
		{
			Crosshair ch;
			try
			{
				ch = Crosshair.instance;
			}
			catch
			{
				ch = null;
			}
			if (ch != null)
			{
				if ((Object)(object)ch.crosshairNormal != (Object)null)
				{
					yield return ch.crosshairNormal;
				}
				if ((Object)(object)ch.crosshairHolding != (Object)null)
				{
					yield return ch.crosshairHolding;
				}
				if ((Object)(object)ch.crosshairWindup != (Object)null)
				{
					yield return (Transform)(object)ch.crosshairWindup;
				}
				if ((Object)(object)ch.wings != (Object)null)
				{
					yield return ch.wings;
				}
			}
		}

		private static ArmHud SafeArmHud(bool hudLikely)
		{
			if (!hudLikely)
			{
				return null;
			}
			try
			{
				return ArmHud.instance;
			}
			catch
			{
				return null;
			}
		}

		private static IEnumerable<Transform> EnumerateHudRoots()
		{
			bool hudLikely = false;
			foreach (Transform item in CrosshairRoots())
			{
				hudLikely = true;
				yield return item;
			}
			PlayerCharacter val = PlayerPalette.FindLocalPlayer();
			if ((Object)(object)val != (Object)null && val.highlighter != null && (Object)(object)val.highlighter.inWorldCrosshair != (Object)null)
			{
				yield return val.highlighter.inWorldCrosshair;
			}
			ArmHud arm = SafeArmHud(hudLikely);
			if (arm == null)
			{
				yield break;
			}
			foreach (Image item2 in ArmHudImages(arm))
			{
				if ((Object)(object)item2 != (Object)null)
				{
					yield return ((Component)item2).transform;
				}
			}
			if ((Object)(object)arm.backpackEmpty != (Object)null)
			{
				yield return arm.backpackEmpty;
			}
			if ((Object)(object)arm.backpackFull != (Object)null)
			{
				yield return arm.backpackFull;
			}
			if ((Object)(object)arm.holsterEmpty != (Object)null)
			{
				yield return arm.holsterEmpty;
			}
			if ((Object)(object)arm.holsterFull != (Object)null)
			{
				yield return arm.holsterFull;
			}
		}

		private static IEnumerable<Image> ArmHudImages(ArmHud arm)
		{
			if (arm != null)
			{
				SingleArmHud[] array = (SingleArmHud[])(object)new SingleArmHud[2] { arm.armHudLeft, arm.armHudRight };
				foreach (SingleArmHud side in array)
				{
					yield return side.waving;
					yield return side.wavingLocked;
					yield return side.wavingLockRing;
					yield return side.airplane;
					yield return side.airplaneLocked;
					yield return side.airplaneLockRing;
				}
			}
		}

		private static string[] ColorPropsFor(Material mat)
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mat == (Object)null || (Object)(object)mat.shader == (Object)null)
			{
				return Array.Empty<string>();
			}
			int instanceID = ((Object)mat.shader).GetInstanceID();
			if (ShaderColorProps.TryGetValue(instanceID, out var value))
			{
				return value;
			}
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			bool flag = default(bool);
			ManualLogSource log;
			try
			{
				int propertyCount = mat.shader.GetPropertyCount();
				for (int i = 0; i < propertyCount; i++)
				{
					if ((int)mat.shader.GetPropertyType(i) != 0)
					{
						continue;
					}
					string propertyName = mat.shader.GetPropertyName(i);
					if (!string.IsNullOrEmpty(propertyName))
					{
						if (propertyName.ToLowerInvariant().Contains("emiss"))
						{
							list2.Add(propertyName);
						}
						else
						{
							list.Add(propertyName);
						}
					}
				}
			}
			catch (Exception ex)
			{
				log = ModSettingsApi.Log;
				if (log != null)
				{
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Shader property scan failed for '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)mat.shader).name);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val);
				}
			}
			if (list.Count == 0)
			{
				string[] colorPropsFallback = ColorPropsFallback;
				foreach (string text in colorPropsFallback)
				{
					if (mat.HasProperty(text))
					{
						list.Add(text);
					}
				}
			}
			if (list.Count == 0 && list2.Count > 0)
			{
				list.AddRange(list2);
			}
			string[] array = list.ToArray();
			ShaderColorProps[instanceID] = array;
			log = ModSettingsApi.Log;
			if (log != null)
			{
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(34, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[HUD] shader '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)mat.shader).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' color properties: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>((array.Length != 0) ? string.Join(", ", array) : "(none)");
				}
				log.LogInfo(val2);
			}
			return array;
		}

		internal static void ApplyHud()
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			if (_activeId == null)
			{
				return;
			}
			try
			{
				Color val = CurrentTint();
				foreach (Transform item in EnumerateHudRoots())
				{
					TintSubtree(item, val);
				}
				Color val2 = default(Color);
				foreach (Graphic previewGraphic in ModSettingsApi.PreviewGraphics)
				{
					if (!((Object)(object)previewGraphic == (Object)null))
					{
						int instanceID = ((Object)previewGraphic).GetInstanceID();
						if (!HudGraphics.ContainsKey(instanceID))
						{
							HudGraphics[instanceID] = (previewGraphic, previewGraphic.color);
						}
						((Color)(ref val2))..ctor(val.r, val.g, val.b, HudGraphics[instanceID].c.a);
						if (previewGraphic.color != val2)
						{
							previewGraphic.color = val2;
						}
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(17, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ApplyHud failed: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val3);
				}
			}
		}

		private static void TintSubtree(Transform root, Color tint)
		{
			//IL_0041: 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)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			Color val2 = default(Color);
			foreach (Graphic componentsInChild in ((Component)root).GetComponentsInChildren<Graphic>(true))
			{
				int instanceID = ((Object)componentsInChild).GetInstanceID();
				Color val;
				if (HudGraphics.TryGetValue(instanceID, out (Graphic, Color) value))
				{
					val = value.Item2;
				}
				else
				{
					val = componentsInChild.color;
					HudGraphics[instanceID] = (componentsInChild, val);
				}
				((Color)(ref val2))..ctor(tint.r, tint.g, tint.b, val.a);
				if (componentsInChild.color != val2)
				{
					componentsInChild.color = val2;
				}
			}
			Color val4 = default(Color);
			Color val6 = default(Color);
			foreach (Renderer componentsInChild2 in ((Component)root).GetComponentsInChildren<Renderer>(true))
			{
				try
				{
					SpriteRenderer val3 = ((Il2CppObjectBase)componentsInChild2).TryCast<SpriteRenderer>();
					if ((Object)(object)val3 != (Object)null)
					{
						int instanceID2 = ((Object)componentsInChild2).GetInstanceID();
						if (!HudSprites.ContainsKey(instanceID2))
						{
							HudSprites[instanceID2] = (val3, val3.color);
						}
						((Color)(ref val4))..ctor(tint.r, tint.g, tint.b, HudSprites[instanceID2].c.a);
						if (val3.color != val4)
						{
							val3.color = val4;
						}
					}
					Material material = componentsInChild2.material;
					if ((Object)(object)material == (Object)null)
					{
						continue;
					}
					string[] array = ColorPropsFor(material);
					if (array.Length == 0)
					{
						continue;
					}
					string text = array[0];
					int instanceID3 = ((Object)componentsInChild2).GetInstanceID();
					Color val5;
					if (HudRenderers.TryGetValue(instanceID3, out (Renderer, string, Color) value2))
					{
						val5 = value2.Item3;
					}
					else
					{
						val5 = material.GetColor(text);
						HudRenderers[instanceID3] = (componentsInChild2, text, val5);
					}
					((Color)(ref val6))..ctor(tint.r, tint.g, tint.b, val5.a);
					if (material.GetColor(text) != val6)
					{
						string[] array2 = array;
						foreach (string text2 in array2)
						{
							material.SetColor(text2, val6);
						}
					}
					if (_mpb == null)
					{
						_mpb = new MaterialPropertyBlock();
					}
					componentsInChild2.GetPropertyBlock(_mpb);
					if (_mpb.GetColor(text) != val6)
					{
						string[] array2 = array;
						foreach (string text3 in array2)
						{
							_mpb.SetColor(text3, val6);
						}
						componentsInChild2.SetPropertyBlock(_mpb);
					}
				}
				catch
				{
				}
			}
		}

		private static void RestoreHud()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00f3: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			foreach (var value in HudGraphics.Values)
			{
				try
				{
					if ((Object)(object)value.g != (Object)null)
					{
						value.g.color = value.c;
					}
				}
				catch
				{
				}
			}
			foreach (var value2 in HudRenderers.Values)
			{
				try
				{
					if (!((Object)(object)value2.r == (Object)null) && !((Object)(object)value2.r.material == (Object)null))
					{
						string[] array = ColorPropsFor(value2.r.material);
						string[] array2 = array;
						foreach (string text in array2)
						{
							value2.r.material.SetColor(text, value2.c);
						}
						if (_mpb == null)
						{
							_mpb = new MaterialPropertyBlock();
						}
						value2.r.GetPropertyBlock(_mpb);
						array2 = array;
						foreach (string text2 in array2)
						{
							_mpb.SetColor(text2, value2.c);
						}
						value2.r.SetPropertyBlock(_mpb);
					}
				}
				catch
				{
				}
			}
			foreach (var value3 in HudSprites.Values)
			{
				try
				{
					if ((Object)(object)value3.r != (Object)null)
					{
						value3.r.color = value3.c;
					}
				}
				catch
				{
				}
			}
			HudGraphics.Clear();
			HudRenderers.Clear();
			HudSprites.Clear();
		}
	}
	[HarmonyPatch]
	internal static class MenuInjector
	{
		private static readonly HashSet<int> InjectedInstances = new HashSet<int>();

		private static readonly List<SettingsRow> CreatedRows = new List<SettingsRow>();

		private static readonly Dictionary<int, Color> BaseLabelColors = new Dictionary<int, Color>();

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

		private static int _reapplyFramesLeft;

		private static readonly List<(GameObject button, SettingsMenu menu, SettingsCatagory cat)> ModsButtons = new List<(GameObject, SettingsMenu, SettingsCatagory)>();

		private const string ModsNoteBase = "Big Walk has no anti-cheat, and these mods\ndon't change how the game plays. ♥";

		private static readonly List<(GameObject note, SettingsCatagory cat, SettingsMenu menu)> ModsNotes = new List<(GameObject, SettingsCatagory, SettingsMenu)>();

		private static readonly List<(GameObject root, SettingsCatagory cat)> CategoryPanels = new List<(GameObject, SettingsCatagory)>();

		private static bool _sliderTickerAdded;

		private static float _nextSliderVisualTick;

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

		private static string _vanillaLeftGlyph;

		private static string _vanillaRightGlyph;

		private static TMP_FontAsset _vanillaArrowFont;

		private const float OptionDownShift = 12f;

		internal static bool AnySettingsMenuOpen => OpenSettingsMenus.Count > 0;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SettingsWardrobe), "GetHangerBySettingsType")]
		private static bool GetHanger_Prefix(SettingsType settingsType, ref ISettingsHanger __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected I4, but got Unknown
			if (!RowRegistry.IsModRow(settingsType))
			{
				return true;
			}
			if (RowRegistry.TryGet((int)settingsType, out var def))
			{
				__result = ((Il2CppObjectBase)def.GetOrCreateHanger()).Cast<ISettingsHanger>();
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SettingsHelper), "GetArrayLabelValue")]
		private static bool GetArrayLabel_Prefix(SettingsType settingsType, int value, ref DisplayType displayType, ref string __result)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected I4, but got Unknown
			if (!RowRegistry.IsModRow(settingsType))
			{
				return true;
			}
			if (RowRegistry.TryGet((int)settingsType, out var def))
			{
				displayType = (DisplayType)1;
				__result = ((def.LabelFor != null) ? def.LabelFor(value) : value.ToString());
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(SettingsRow), "Refresh")]
		private static bool RowRefresh_Prefix(SettingsRow __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected I4, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			try
			{
				if (!RowRegistry.IsModRow(__instance.settingsType))
				{
					return true;
				}
				if (!RowRegistry.TryGet((int)__instance.settingsType, out var def))
				{
					return true;
				}
				if (def.Kind != ModRowKind.Slider)
				{
					return true;
				}
				SyncSliderRow(__instance, def);
				return false;
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Row refresh prefix failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val);
				}
				return true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SettingsRow), "Refresh")]
		private static void RowRefresh_Postfix(SettingsRow __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected I4, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!RowRegistry.IsModRow(__instance.settingsType) || !RowRegistry.TryGet((int)__instance.settingsType, out var def) || def.Kind == ModRowKind.Slider)
				{
					return;
				}
				if (def.UseDiscrete)
				{
					SyncDiscreteRow(__instance, def);
					return;
				}
				ShowArrows(__instance);
				SetArrowGlyphs(__instance);
				if (def.LabelColorFor == null || (Object)(object)__instance.arrayLabel == (Object)null)
				{
					return;
				}
				TMP_Text val = __instance.arrayLabel.textElement ?? ((Component)__instance.arrayLabel).GetComponent<TMP_Text>();
				if (!((Object)(object)val == (Object)null))
				{
					int instanceID = ((Object)val).GetInstanceID();
					if (!BaseLabelColors.ContainsKey(instanceID))
					{
						BaseLabelColors[instanceID] = ((Graphic)val).color;
					}
					((Graphic)val).color = (Color)(((??)def.LabelColorFor(def.Value)) ?? BaseLabelColors[instanceID]);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Row refresh postfix failed: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val2);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SettingsMenu), "OnDisable")]
		private static void SettingsMenuOnDisable_Postfix(SettingsMenu __instance)
		{
			try
			{
				OpenSettingsMenus.Remove(((Object)__instance).GetInstanceID());
			}
			catch
			{
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SettingsMenu), "OnEnable")]
		private static void SettingsMenuOnEnable_Postfix(SettingsMenu __instance)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			try
			{
				OpenSettingsMenus.Add(((Object)__instance).GetInstanceID());
				if (RowRegistry.RowOrder.Count != 0)
				{
					if (InjectedInstances.Add(((Object)__instance).GetInstanceID()))
					{
						Inject(__instance);
					}
					NotifyMenuOpened();
					HarvestVanillaArrowGlyphs(__instance);
					RefreshModRows();
					RequestRowReapply();
					RowScroller.ResetToTop();
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("sMods category injection failed: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					log.LogError(val);
				}
			}
		}

		private static void NotifyMenuOpened()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			bool flag = default(bool);
			foreach (Action item in RowRegistry.MenuOpened)
			{
				try
				{
					item();
				}
				catch (Exception ex)
				{
					ManualLogSource log = ModSettingsApi.Log;
					if (log != null)
					{
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("OnMenuOpened handler failed: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						}
						log.LogWarning(val);
					}
				}
			}
		}

		internal static void RefreshModRowsPublic()
		{
			RefreshModRows();
		}

		internal static void RequestRowReapply()
		{
			_reapplyFramesLeft = 6;
		}

		internal static void TickRowReapply()
		{
			if (_reapplyFramesLeft <= 0)
			{
				return;
			}
			_reapplyFramesLeft--;
			try
			{
				RefreshModRows();
			}
			catch
			{
			}
		}

		internal static void HandleSelectionChanged(GameObject selected)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			bool flag = default(bool);
			for (int num = ModsButtons.Count - 1; num >= 0; num--)
			{
				(GameObject, SettingsMenu, SettingsCatagory) tuple = ModsButtons[num];
				if ((Object)(object)tuple.Item1 == (Object)null || (Object)(object)tuple.Item2 == (Object)null || (Object)(object)tuple.Item3 == (Object)null)
				{
					ModsButtons.RemoveAt(num);
				}
				else if (((Object)tuple.Item1).GetInstanceID() == ((Object)selected).GetInstanceID())
				{
					try
					{
						tuple.Item2.PressCatagoryButton(tuple.Item3);
						break;
					}
					catch (Exception ex)
					{
						ManualLogSource log = ModSettingsApi.Log;
						if (log != null)
						{
							BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(33, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Selecting sMods category failed: ");
								((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
							}
							log.LogWarning(val);
						}
						break;
					}
				}
			}
		}

		internal static void RegisterCategoryPanel(GameObject root, SettingsCatagory cat)
		{
			root.SetActive(false);
			CategoryPanels.Add((root, cat));
		}

		private static string ComposeNoteText()
		{
			List<(int, string)> list = new List<(int, string)>();
			foreach (var noteLine in RowRegistry.NoteLines)
			{
				int item = noteLine.order;
				Func<string> item2 = noteLine.line;
				string text = null;
				try
				{
					text = item2();
				}
				catch
				{
				}
				if (!string.IsNullOrEmpty(text))
				{
					list.Add((item, text));
				}
			}
			list.Sort(((int order, string text) a, (int order, string text) b) => a.order.CompareTo(b.order));
			StringBuilder stringBuilder = new StringBuilder();
			foreach (var item4 in list)
			{
				string item3 = item4.Item2;
				stringBuilder.Append(item3).Append('\n');
			}
			stringBuilder.Append("Big Walk has no anti-cheat, and these mods\ndon't change how the game plays. ♥");
			return stringBuilder.ToString();
		}

		private static void CreateModsNote(SettingsMenu menu, SettingsCatagory modsCat)
		{
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			bool flag = default(bool);
			try
			{
				VersionDisplay componentInChildren = ((Component)menu).GetComponentInChildren<VersionDisplay>(true);
				if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.textField == (Object)null)
				{
					ManualLogSource log = ModSettingsApi.Log;
					if (log != null)
					{
						log.LogWarning((object)"VersionDisplay not found; skipping sMods note");
					}
					return;
				}
				GameObject gameObject = ((Component)componentInChildren).gameObject;
				GameObject val = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
				((Object)val).name = "ModsNote";
				VersionDisplay component = val.GetComponent<VersionDisplay>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				foreach (LocalizedText componentsInChild in val.GetComponentsInChildren<LocalizedText>(true))
				{
					Object.Destroy((Object)(object)componentsInChild);
				}
				RectTransform component2 = gameObject.GetComponent<RectTransform>();
				RectTransform component3 = val.GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null && (Object)(object)component3 != (Object)null)
				{
					component3.anchoredPosition = component2.anchoredPosition + new Vector2(0f, -125f);
					component3.sizeDelta = new Vector2(Mathf.Max(component2.sizeDelta.x, 420f), 170f);
				}
				TMP_Text val2 = val.GetComponent<TMP_Text>() ?? val.GetComponentInChildren<TMP_Text>(true);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.text = ComposeNoteText();
					val2.richText = true;
					val2.enableWordWrapping = true;
					val2.alignment = (TextAlignmentOptions)260;
					val2.overflowMode = (TextOverflowModes)0;
				}
				val.SetActive(false);
				ModsNotes.Add((val, modsCat, menu));
				if ((Object)(object)ModSettingsApi.MenuGlyphFont == (Object)null)
				{
					ModSettingsApi.MenuGlyphFont = FindRowLabelFont(menu);
				}
				ModPanelContext obj = new ModPanelContext(val, modsCat, menu);
				List<(int, Action<ModPanelContext>)> list = new List<(int, Action<ModPanelContext>)>(RowRegistry.PanelProviders);
				list.Sort(((int order, Action<ModPanelContext> build) a, (int order, Action<ModPanelContext> build) b) => a.order.CompareTo(b.order));
				foreach (var (num, action) in list)
				{
					try
					{
						action(obj);
					}
					catch (Exception ex)
					{
						ManualLogSource log2 = ModSettingsApi.Log;
						if (log2 != null)
						{
							BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(32, 2, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Panel provider (order ");
								((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<int>(num);
								((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(") failed: ");
								((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
							}
							log2.LogWarning(val3);
						}
					}
				}
				ManualLogSource log3 = ModSettingsApi.Log;
				if (log3 != null)
				{
					log3.LogInfo((object)"sMods note created under the settings heading");
				}
			}
			catch (Exception ex2)
			{
				ManualLogSource log2 = ModSettingsApi.Log;
				if (log2 != null)
				{
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Creating sMods note failed: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message);
					}
					log2.LogWarning(val3);
				}
			}
		}

		private static TMP_FontAsset FindRowLabelFont(SettingsMenu menu)
		{
			try
			{
				if ((Object)(object)menu == (Object)null)
				{
					return null;
				}
				Il2CppArrayBase<SettingsRow> componentsInChildren = ((Component)menu).GetComponentsInChildren<SettingsRow>(true);
				if (componentsInChildren == null)
				{
					return null;
				}
				foreach (SettingsRow item in componentsInChildren)
				{
					if (!((Object)(object)item == (Object)null) && !((Object)(object)item.arrayLabel == (Object)null))
					{
						TMP_Text val = ((Component)item.arrayLabel).GetComponent<TMP_Text>();
						if ((Object)(object)val == (Object)null)
						{
							val = ((Component)item.arrayLabel).GetComponentInChildren<TMP_Text>(true);
						}
						if ((Object)(object)val != (Object)null && (Object)(object)val.font != (Object)null)
						{
							return val.font;
						}
					}
				}
			}
			catch
			{
			}
			return null;
		}

		internal static void UpdateModsNote(SettingsCatagory activeCatagory)
		{
			for (int num = ModsNotes.Count - 1; num >= 0; num--)
			{
				(GameObject, SettingsCatagory, SettingsMenu) tuple = ModsNotes[num];
				if ((Object)(object)tuple.Item1 == (Object)null || (Object)(object)tuple.Item2 == (Object)null)
				{
					ModsNotes.RemoveAt(num);
				}
				else
				{
					try
					{
						bool flag = (Object)(object)activeCatagory != (Object)null && ((Object)activeCatagory).GetInstanceID() == ((Object)tuple.Item2).GetInstanceID();
						if (flag)
						{
							TMP_Text val = tuple.Item1.GetComponent<TMP_Text>() ?? tuple.Item1.GetComponentInChildren<TMP_Text>(true);
							if ((Object)(object)val != (Object)null)
							{
								string text = ComposeNoteText();
								if (val.text != text)
								{
									val.text = text;
								}
							}
						}
						if (tuple.Item1.activeSelf != flag)
						{
							tuple.Item1.SetActive(flag);
						}
					}
					catch
					{
					}
				}
			}
			for (int num2 = CategoryPanels.Count - 1; num2 >= 0; num2--)
			{
				var (val2, val3) = CategoryPanels[num2];
				if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
				{
					CategoryPanels.RemoveAt(num2);
				}
				else
				{
					try
					{
						bool flag2 = (Object)(object)activeCatagory != (Object)null && ((Object)activeCatagory).GetInstanceID() == ((Object)val3).GetInstanceID();
						if (val2.activeSelf != flag2)
						{
							val2.SetActive(flag2);
						}
					}
					catch
					{
					}
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(SettingsMenu), "SwapToCatagory")]
		private static void SwapToCatagory_Postfix(SettingsCatagory newCatagory)
		{
			UpdateModsNote(newCatagory);
			foreach (var modsNote in ModsNotes)
			{
				if (!((Object)(object)modsNote.cat == (Object)null) && !((Object)(object)newCatagory == (Object)null) && ((Object)modsNote.cat).GetInstanceID() == ((Object)newCatagory).GetInstanceID())
				{
					if ((Object)(object)modsNote.menu != (Object)null)
					{
						HarvestVanillaArrowGlyphs(modsNote.menu);
					}
					RefreshModRows();
					RequestRowReapply();
				}
			}
		}

		private static bool IsDiscreteLabel(SettingsRow row, LocalizedText lt)
		{
			try
			{
				TMP_Text[] array = (TMP_Text[])(object)new TMP_Text[3] { row.label0, row.label1, row.label2 };
				foreach (TMP_Text val in array)
				{
					if (!((Object)(object)val == (Object)null))
					{
						if ((Object)(object)lt.textElement != (Object)null && ((Object)lt.textElement).GetInstanceID() == ((Object)val).GetInstanceID())
						{
							return true;
						}
						if (((Object)((Component)lt).gameObject).GetInstanceID() == ((Object)((Component)val).gameObject).GetInstanceID())
						{
							return true;
						}
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private static void ShowArrows(SettingsRow row)
		{
			try
			{
				ShowArrow(row.leftButton);
				ShowArrow(row.rightButton);
			}
			catch
			{
			}
		}

		private static void ShowArrow(Button button)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0088: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)button == (Object)null)
			{
				return;
			}
			((Component)button).gameObject.SetActive(true);
			foreach (CanvasGroup componentsInChild in ((Component)button).GetComponentsInChildren<CanvasGroup>(true))
			{
				componentsInChild.alpha = 1f;
			}
			foreach (Graphic componentsInChild2 in ((Component)button).GetComponentsInChildren<Graphic>(true))
			{
				Color color = componentsInChild2.color;
				if ((Object)(object)((Il2CppObjectBase)componentsInChild2).TryCast<TMP_Text>() != (Object)null)
				{
					if (color.a < 0.99f)
					{
						componentsInChild2.color = new Color(color.r, color.g, color.b, 1f);
					}
					continue;
				}
				Image val = ((Il2CppObjectBase)componentsInChild2).TryCast<Image>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.sprite == (Object)null)
				{
					if (!((Object)componentsInChild2).name.ToLowerInvariant().Contains("highlight") && color.a > 0.001f)
					{
						componentsInChild2.color = new Color(color.r, color.g, color.b, 0f);
					}
				}
				else if (color.a < 0.99f)
				{
					componentsInChild2.color = new Color(color.r, color.g, color.b, 1f);
				}
			}
		}

		private static void RefreshModRows()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected I4, but got Unknown
			CreatedRows.RemoveAll((SettingsRow r) => (Object)(object)r == (Object)null);
			bool flag = default(bool);
			foreach (SettingsRow createdRow in CreatedRows)
			{
				try
				{
					if (!RowRegistry.TryGet((int)createdRow.settingsType, out var def))
					{
						createdRow.Refresh();
						continue;
					}
					ApplyRowVisibility(createdRow, def);
					if (def.Kind == ModRowKind.Slider)
					{
						SyncSliderRow(createdRow, def);
					}
					else
					{
						createdRow.Refresh();
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log = ModSettingsApi.Log;
					if (log != null)
					{
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Row refresh failed for '");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)createdRow).name);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
						}
						log.LogWarning(val);
					}
				}
			}
			RowScroller.MarkDirty();
		}

		private static void ApplyRowVisibility(SettingsRow row, ModRowDef def)
		{
			if (def.VisibleWhen != null)
			{
				bool flag;
				try
				{
					flag = def.VisibleWhen();
				}
				catch
				{
					flag = true;
				}
				GameObject gameObject = ((Component)row).gameObject;
				if ((Object)(object)gameObject != (Object)null && gameObject.activeSelf != flag)
				{
					gameObject.SetActive(flag);
				}
			}
		}

		private static void ConfigureSliderRow(SettingsRow row, ModRowDef def)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			Slider slider = row.slider;
			if ((Object)(object)slider == (Object)null)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Slider template has no slider for '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(def.Title);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
					}
					log.LogWarning(val);
				}
				return;
			}
			if (def.CenterSliderLabel)
			{
				CenterSliderLabel(row);
			}
			if (def.LabelColorFor != null)
			{
				try
				{
					if ((Object)(object)row.sliderLabel != (Object)null)
					{
						ModSettingsApi.RegisterColorRoot(((Component)row.sliderLabel).transform);
					}
					if ((Object)(object)row.slider != (Object)null && (Object)(object)row.slider.handleRect != (Object)null)
					{
						ModSettingsApi.RegisterColorRoot((Transform)(object)row.slider.handleRect);
					}
				}
				catch
				{
				}
			}
			if (!_sliderTickerAdded && (def.LabelColorFor != null || def.CenterSliderLabel))
			{
				_sliderTickerAdded = true;
				RowRegistry.MenuTickers.Add(TickSliderVisuals);
			}
			slider.minValue = def.SliderMin;
			slider.maxValue = def.SliderMax;
			slider.wholeNumbers = true;
			int step = ((def.SliderStep > 0) ? def.SliderStep : 5);
			slider.onValueChanged = new SliderEvent();
			((UnityEvent<float>)(object)slider.onValueChanged).AddListener(UnityAction<float>.op_Implicit((Action<float>)delegate(float f)
			{
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Expected O, but got Unknown
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Expected O, but got Unknown
				bool flag2 = default(bool);
				try
				{
					int num = def.SliderMin + Mathf.RoundToInt((f - (float)def.SliderMin) / (float)step) * step;
					num = Mathf.Clamp(num, def.SliderMin, def.SliderMax);
					SettingsHanger orCreateHanger = def.GetOrCreateHanger();
					if (orCreateHanger.value != num)
					{
						orCreateHanger.value = num;
						orCreateHanger.Save();
						try
						{
							def.OnApply?.Invoke(num);
						}
						catch (Exception ex)
						{
							ManualLogSource log2 = ModSettingsApi.Log;
							if (log2 != null)
							{
								BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(17, 2, ref flag2);
								if (flag2)
								{
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(def.Title);
									((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] apply failed: ");
									((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
								}
								log2.LogError(val2);
							}
						}
						UpdateSliderLabel(row, def);
					}
				}
				catch (Exception ex2)
				{
					ManualLogSource log2 = ModSettingsApi.Log;
					if (log2 != null)
					{
						BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Slider change failed: ");
							((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message);
						}
						log2.LogWarning(val3);
					}
				}
			}));
			SyncSliderRow(row, def);
		}

		private static void SyncSliderRow(SettingsRow row, ModRowDef def)
		{
			if (!((Object)(object)row.slider == (Object)null))
			{
				row.slider.SetValueWithoutNotify((float)def.Value);
				UpdateSliderLabel(row, def);
			}
		}

		private static void UpdateSliderLabel(SettingsRow row, ModRowDef def)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_00d6: 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)
			if ((Object)(object)row.sliderLabel == (Object)null)
			{
				return;
			}
			string text = ((def.LabelFor != null) ? def.LabelFor(def.Value) : def.Value.ToString());
			SetLiteral(row.sliderLabel, text);
			if (def.LabelColorFor == null)
			{
				return;
			}
			try
			{
				TMP_Text val = row.sliderLabel.textElement ?? ((Component)row.sliderLabel).GetComponent<TMP_Text>();
				if (!((Object)(object)val == (Object)null))
				{
					Color? val2 = def.LabelColorFor(def.Value);
					Color val3;
					if (val2.HasValue)
					{
						val3 = val2.Value;
					}
					else
					{
						TMP_Text val4 = (((Object)(object)row.title != (Object)null) ? (row.title.textElement ?? ((Component)row.title).GetComponent<TMP_Text>()) : null);
						val3 = (((Object)(object)val4 != (Object)null) ? ((Graphic)val4).color : ((Graphic)val).color);
					}
					val3.a = 1f;
					if (((Graphic)val).color != val3)
					{
						((Graphic)val).color = val3;
					}
					TintSliderHandle(row, def);
				}
			}
			catch
			{
			}
		}

		private static void TintSliderHandle(SettingsRow row, ModRowDef def)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				RectTransform val = (((Object)(object)row.slider != (Object)null) ? row.slider.handleRect : null);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Color val2 = (Color)(((??)((def.LabelColorFor != null) ? def.LabelColorFor(def.Value) : ((Color?)null))) ?? Color.white);
				val2.a = 1f;
				Il2CppArrayBase<Graphic> componentsInChildren = ((Component)val).GetComponentsInChildren<Graphic>(true);
				if (componentsInChildren == null)
				{
					return;
				}
				foreach (Graphic item in componentsInChildren)
				{
					if (!((Object)(object)item == (Object)null) && item.color != val2)
					{
						item.color = val2;
					}
				}
			}
			catch
			{
			}
		}

		private static void CenterSliderLabel(SettingsRow row)
		{
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				LocalizedText sliderLabel = row.sliderLabel;
				if ((Object)(object)sliderLabel == (Object)null || (Object)(object)row.slider == (Object)null)
				{
					return;
				}
				RectTransform val = ((Il2CppObjectBase)((Component)row.slider).transform).TryCast<RectTransform>();
				RectTransform val2 = ((Il2CppObjectBase)((Component)sliderLabel).transform).TryCast<RectTransform>();
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
				{
					((Transform)val2).position = ((Transform)val).TransformPoint(new Vector3(0f, 26f, 0f));
					val2.sizeDelta = new Vector2(420f, Mathf.Max(val2.sizeDelta.y, 40f));
					TMP_Text val3 = sliderLabel.textElement ?? ((Component)sliderLabel).GetComponent<TMP_Text>();
					if ((Object)(object)val3 != (Object)null)
					{
						val3.alignment = (TextAlignmentOptions)514;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("CenterSliderLabel failed: ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val4);
				}
			}
		}

		private static void TickSliderVisuals()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected I4, but got Unknown
			if (Time.unscaledTime < _nextSliderVisualTick)
			{
				return;
			}
			_nextSliderVisualTick = Time.unscaledTime + 0.25f;
			CreatedRows.RemoveAll((SettingsRow r) => (Object)(object)r == (Object)null);
			foreach (SettingsRow createdRow in CreatedRows)
			{
				try
				{
					if (!RowRegistry.TryGet((int)createdRow.settingsType, out var def) || !((Component)createdRow).gameObject.activeInHierarchy)
					{
						continue;
					}
					if (def.Kind == ModRowKind.Slider)
					{
						if (def.LabelColorFor != null || def.CenterSliderLabel)
						{
							UpdateSliderLabel(createdRow, def);
						}
					}
					else if (def.UseDiscrete)
					{
						SyncDiscreteRow(createdRow, def);
					}
				}
				catch
				{
				}
			}
		}

		private static SettingsRow FindArrayTemplate(SettingsMenu menu)
		{
			SettingsCatagory[] array = (SettingsCatagory[])(object)new SettingsCatagory[4] { menu.catagoryGraphics, menu.catagoryAudio, menu.catagoryGeneral, menu.catagoryControls };
			foreach (SettingsCatagory val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				foreach (SettingsRow componentsInChild in ((Component)val).GetComponentsInChildren<SettingsRow>(true))
				{
					if ((Object)(object)componentsInChild.leftButton != (Object)null && (Object)(object)componentsInChild.rightButton != (Object)null && (Object)(object)componentsInChild.arrayLabel != (Object)null && (Object)(object)componentsInChild.slider == (Object)null)
					{
						return componentsInChild;
					}
				}
			}
			return null;
		}

		private static SettingsRow FindDiscreteTemplate(SettingsMenu menu)
		{
			SettingsCatagory[] array = (SettingsCatagory[])(object)new SettingsCatagory[4] { menu.catagoryGraphics, menu.catagoryGeneral, menu.catagoryControls, menu.catagoryAudio };
			foreach (SettingsCatagory val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				foreach (SettingsRow componentsInChild in ((Component)val).GetComponentsInChildren<SettingsRow>(true))
				{
					if ((Object)(object)componentsInChild.label0 != (Object)null && (Object)(object)componentsInChild.label1 != (Object)null && (Object)(object)componentsInChild.slider == (Object)null && (Object)(object)componentsInChild.leftButton == (Object)null)
					{
						return componentsInChild;
					}
				}
			}
			return null;
		}

		private static void SyncDiscreteRow(SettingsRow row, ModRowDef def)
		{
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				List<TMP_Text> list = new List<TMP_Text>();
				TMP_Text[] array = (TMP_Text[])(object)new TMP_Text[3] { row.label0, row.label1, row.label2 };
				foreach (TMP_Text val in array)
				{
					if ((Object)(object)val != (Object)null)
					{
						list.Add(val);
					}
				}
				int[] possibleValues = def.PossibleValues;
				for (int j = 0; j < list.Count; j++)
				{
					TMP_Text val2 = list[j];
					if (!((Object)(object)val2 == (Object)null))
					{
						if (possibleValues == null || j >= possibleValues.Length)
						{
							((Component)val2).gameObject.SetActive(false);
							continue;
						}
						((Component)val2).gameObject.SetActive(true);
						val2.text = ((def.LabelFor != null) ? def.LabelFor(possibleValues[j]) : possibleValues[j].ToString());
						bool flag = def.Value == possibleValues[j];
						val2.fontStyle = (FontStyles)(flag ? (val2.fontStyle | 4) : (val2.fontStyle & -5));
					}
				}
				TidyDiscreteContainers(list, (possibleValues != null) ? Math.Min(possibleValues.Length, list.Count) : list.Count, row);
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag2 = default(bool);
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(33, 2, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Discrete row sync failed for '");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(def.Title);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("': ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val3);
				}
			}
		}

		private static void TidyDiscreteContainers(List<TMP_Text> labels, int n, SettingsRow row)
		{
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (labels.Count == 0)
				{
					return;
				}
				Transform parent = labels[0].transform.parent;
				if ((Object)(object)parent == (Object)null || (Object)(object)parent == (Object)(object)((Component)row).transform)
				{
					return;
				}
				Transform parent2 = parent.parent;
				if ((Object)(object)parent2 == (Object)null)
				{
					return;
				}
				Dictionary<int, int> dictionary = new Dictionary<int, int>();
				for (int i = 0; i < labels.Count; i++)
				{
					if (!((Object)(object)labels[i] == (Object)null))
					{
						Transform parent3 = labels[i].transform.parent;
						if ((Object)(object)parent3 != (Object)null && (Object)(object)parent3.parent == (Object)(object)parent2)
						{
							dictionary[parent3.GetSiblingIndex()] = i;
						}
					}
				}
				if (dictionary.Count == 0)
				{
					return;
				}
				int num = 0;
				for (int j = 0; j < parent2.childCount; j++)
				{
					Transform child = parent2.GetChild(j);
					bool flag;
					if (dictionary.TryGetValue(j, out var value))
					{
						flag = value < n;
						if (flag)
						{
							num++;
						}
					}
					else
					{
						flag = num >= 1 && num < n;
					}
					if (((Component)child).gameObject.activeSelf != flag)
					{
						((Component)child).gameObject.SetActive(flag);
					}
				}
				int instanceID = ((Object)row).GetInstanceID();
				if (!((Component)row).gameObject.activeInHierarchy || CenteredDiscreteRows.Contains(instanceID))
				{
					return;
				}
				CenteredDiscreteRows.Add(instanceID);
				float num2 = 0f;
				float num3 = 0f;
				int num4 = 0;
				int num5 = 0;
				foreach (KeyValuePair<int, int> item in dictionary)
				{
					float x = parent2.GetChild(item.Key).position.x;
					num2 += x;
					num4++;
					if (item.Value < n)
					{
						num3 += x;
						num5++;
					}
				}
				if (num4 <= 0 || num5 <= 0 || num5 >= num4)
				{
					return;
				}
				float num6 = num2 / (float)num4 - num3 / (float)num5;
				float x2 = parent2.InverseTransformVector(new Vector3(num6, 0f, 0f)).x;
				if (!(Mathf.Abs(x2) > 0.05f))
				{
					return;
				}
				for (int k = 0; k < parent2.childCount; k++)
				{
					Transform child2 = parent2.GetChild(k);
					if (((Component)child2).gameObject.activeSelf)
					{
						Vector3 localPosition = child2.localPosition;
						localPosition.x += x2;
						child2.localPosition = localPosition;
					}
				}
			}
			catch
			{
			}
		}

		private static void HarvestVanillaArrowGlyphs(SettingsMenu menu)
		{
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			if (!string.IsNullOrEmpty(_vanillaLeftGlyph) && !string.IsNullOrEmpty(_vanillaRightGlyph))
			{
				return;
			}
			bool flag = default(bool);
			try
			{
				SettingsCatagory[] array = (SettingsCatagory[])(object)new SettingsCatagory[4] { menu.catagoryGeneral, menu.catagoryGraphics, menu.catagoryAudio, menu.catagoryControls };
				foreach (SettingsCatagory val in array)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					foreach (SettingsRow componentsInChild in ((Component)val).GetComponentsInChildren<SettingsRow>(true))
					{
						if ((Object)(object)componentsInChild.leftButton == (Object)null || (Object)(object)componentsInChild.rightButton == (Object)null || RowRegistry.IsModRow(componentsInChild.settingsType))
						{
							continue;
						}
						TMP_Text val2 = FirstText(componentsInChild.leftButton);
						TMP_Text val3 = FirstText(componentsInChild.rightButton);
						if (!((Object)(object)val2 != (Object)null) || !((Object)(object)val3 != (Object)null) || string.IsNullOrEmpty(val2.text) || string.IsNullOrEmpty(val3.text) || !(val2.text != "<") || !(val3.text != ">"))
						{
							continue;
						}
						_vanillaLeftGlyph = val2.text;
						_vanillaRightGlyph = val3.text;
						_vanillaArrowFont = (((Object)(object)val2.font != (Object)null) ? val2.font : val3.font);
						ManualLogSource log = ModSettingsApi.Log;
						if (log != null)
						{
							BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(49, 4, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Arrow glyphs harvested from '");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(((Object)componentsInChild).name);
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("': L='");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(_vanillaLeftGlyph);
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' R='");
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(_vanillaRightGlyph);
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("' font='");
								TMP_FontAsset vanillaArrowFont = _vanillaArrowFont;
								((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>((vanillaArrowFont != null) ? ((Object)vanillaArrowFont).name : null);
								((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("'");
							}
							log.LogInfo(val4);
						}
						RefreshModRows();
						return;
					}
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(28, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Arrow glyph harvest failed: ");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val5);
				}
			}
		}

		private static TMP_Text FirstText(Button button)
		{
			foreach (Graphic componentsInChild in ((Component)button).GetComponentsInChildren<Graphic>(true))
			{
				TMP_Text val = ((Il2CppObjectBase)componentsInChild).TryCast<TMP_Text>();
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private static void SetArrowGlyphs(SettingsRow row)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			try
			{
				TMP_FontAsset val = (((Object)(object)row.arrayLabel != (Object)null && (Object)(object)row.arrayLabel.textElement != (Object)null) ? row.arrayLabel.textElement.font : null);
				bool flag = !string.IsNullOrEmpty(_vanillaLeftGlyph) && !string.IsNullOrEmpty(_vanillaRightGlyph);
				TMP_FontAsset val2 = _vanillaArrowFont ?? val;
				ApplyGlyph(row.leftButton, flag ? _vanillaLeftGlyph : "<", flag ? val2 : val);
				ApplyGlyph(row.rightButton, flag ? _vanillaRightGlyph : ">", flag ? val2 : val);
			}
			catch (Exception ex)
			{
				ManualLogSource log = ModSettingsApi.Log;
				if (log != null)
				{
					bool flag2 = default(bool);
					BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Arrow glyph assign failed: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val3);
				}
			}
		}

		private static void ApplyGlyph(Button button, string glyph, TMP_FontAsset overrideFont)
		{
			//IL_0041: 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)
			//IL_0047: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)button == (Object)null)
			{
				return;
			}
			TMP_Text val = FirstText(button);
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)overrideFont != (Object)null)
				{
					val.font = overrideFont;
				}
				if (val.text != glyph)
				{
					val.text = glyph;
				}
				Color color = ((Graphic)val).color;
				if (color.a < 0.99f)
				{
					((Graphic)val).color = new Color(color.r, color.g, color.b, 1f);
				}
			}
		}

		private static SettingsRow FindSliderTemplate(SettingsMenu menu)
		{
			SettingsCatagory[] array = (SettingsCatagory[])(object)new SettingsCatagory[4] { menu.catagoryAudio, menu.catagoryGraphics, menu.catagoryGeneral, menu.catagoryControls };
			foreach (SettingsCatagory val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				foreach (SettingsRow componentsInChild in ((Component)val).GetComponentsInChildren<SettingsRow>(true))
				{
					if ((Object)(object)componentsInChild.slider != (Object)null && (Object)(object)componentsInChild.leftButton == (Object)null)
					{
						return componentsInChild;
					}
				}
			}
			return null;
		}

		private static void Inject(SettingsMenu menu)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Expected O, but got Unknown
			//IL_080d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0814: Expected O, but got Unknown
			//IL_0a8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a93: Expected O, but got Unknown
			//IL_0ae0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aea: Expected O, but got Unknown
			//IL_0b6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b75: Expected O, but got Unknown
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0614: Expected I4, but got Unknown
			//IL_089d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a7: Expected O, but got Unknown
			//IL_0a10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a15: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a17: 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_01fa: Expected O, but got Unknown
			//IL_0a2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a34: Expected O, but got Unknown
			//IL_09e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a08: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Expected O, but got Unknown
			//IL_0798: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Expected O, but got Unknown
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Invalid comparison between Unknown and I4
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Expected O, but got Unknown
			ManualLogSource log = ModSettingsApi.Log;
			ManualLogSource val = log;
			bool flag = default(bool);
			if (val != null)
			{
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(57, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Injecting sMods category into SettingsMenu '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)((Component)menu).gameObject).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' (mainMenu=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<bool>(menu.isInMainMenu);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")");
				}
				val.LogInfo(val2);
			}
			RowRegistry.Injected = true;
			SettingsCatagory catagoryGeneral = menu.catagoryGeneral;
			SettingsCatagory catagoryControls = menu.catagoryControls;
			SettingsCatagory catagoryRebind = menu.catagoryRebind;
			if ((Object)(object)catagoryGeneral == (Object)null || (Object)(object)catagoryRebind == (Object)null)
			{
				if (log != null)
				{
					log.LogError((object)"catagoryGeneral/catagoryRebind missing; aborting injection");
				}
				return;
			}
			GameObject val3 = Object.Instantiate<GameObject>(((Component)catagoryGeneral).gameObject, ((Component)catagoryGeneral).transform.parent);
			((Object)val3).name = "CatagoryMods";
			val3.SetActive(false);
			SettingsCatagory modsCat = val3.GetComponent<SettingsCatagory>();
			Il2CppArrayBase<SettingsRow> componentsInChildren = val3.GetComponentsInChildren<SettingsRow>(true);
			if (componentsInChildren == null || componentsInChildren.Length == 0)
			{
				if (log != null)
				{
					log.LogError((object)"No SettingsRow children found in cloned category; aborting");
				}
				Object.Destroy((Object)(object)val3);
				return;
			}
			SettingsRow val4 = null;
			SettingsRow val5 = null;
			foreach (SettingsRow item3 in componentsInChildren)
			{
				if ((Object)(object)val4 == (Object)null && (Object)(object)item3.leftButton != (Object)null && (Object)(object)item3.rightButton != (Object)null && (Object)(object)item3.arrayLabel != (Object)null)
				{
					val4 = item3;
				}
				if ((Object)(object)val5 == (Object)null && (Object)(object)item3.boringButton != (Object)null)
				{
					val5 = item3;
				}
			}
			SettingsRow arrayTemplate = FindArrayTemplate(menu) ?? val4;
			SettingsRow sliderTemplate = FindSliderTemplate(menu);
			val = log;
			if (val != null)
			{
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(34, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Templates: array=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)(object)arrayTemplate != (Object)null) ? ((Object)arrayTemplate).name : "NONE");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", slider=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)(object)sliderTemplate != (Object)null) ? ((Object)sliderTemplate).name : "NONE");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", reset=");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)(object)val5 != (Object)null) ? ((Object)val5).name : "NONE");
				}
				val.LogInfo(val2);
			}
			if ((Object)(object)arrayTemplate == (Object)null || (Object)(object)val4 == (Object)null)
			{
				if (log != null)
				{
					log.LogError((object)"No array row template found; aborting");
				}
				Object.Destroy((Object)(object)val3);
				return;
			}
			Transform parent = ((Component)val4).transform.parent;
			int siblingIndex = ((Component)val4).transform.GetSiblingIndex();
			List<SettingsRow> list = new List<SettingsRow>();
			SettingsRow discreteTemplate = FindDiscreteTemplate(menu);
			val = log;
			if (val != null)
			{
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Discrete template: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)(object)discreteTemplate != (Object)null) ? ((Object)discreteTemplate).name : "NONE");
				}
				val.LogInfo(val2);
			}
			foreach (ModRowDef item4 in RowRegistry.Ordered())
			{
				if (!item4.InGeneral && !item4.InControls)
				{
					SettingsRow val6 = BuildRow(item4, parent, siblingIndex + list.Count);
					ShiftRowOptionsDown(val6, 12f);
					list.Add(val6);
				}
			}
			try
			{
				SettingsRow val7 = null;
				foreach (SettingsRow componentsInChild in ((Component)catagoryGeneral).GetComponentsInChildren<SettingsRow>(true))
				{
					if ((Object)(object)componentsInChild != (Object)null && (int)componentsInChild.settingsType == 12)
					{
						val7 = componentsInChild;
						break;
					}
				}
				if ((Object)(object)val7 != (Object)null && RowRegistry.HideVanillaCrosshair && ((Component)val7).gameObject.activeSelf)
				{
					((Component)val7).gameObject.SetActive(false);
				}
				List<SettingsRow> list2 = new List<SettingsRow>();
				foreach (ModRowDef item5 in RowRegistry.Ordered())
				{
					if (item5.InGeneral)
					{
						Transform parent2;
						int siblingIndex2;
						if ((Object)(object)val7 != (Object)null)
						{
							parent2 = ((Component)val7).transform.parent;
							siblingIndex2 = ((Component)val7).transform.GetSiblingIndex() + 1 + list2.Count;
						}
						else
						{
							parent2 = parent;
							siblingIndex2 = siblingIndex + list.Count;
						}
						SettingsRow item = BuildRow(item5, parent2, siblingIndex2);
						if ((Object)(object)val7 == (Object)null)
						{
							list.Add(item);
						}
						else
						{
							list2.Add(item);
						}
					}
				}
				if (list2.Count > 0)
				{
					List<SettingsRow> list3 = new List<SettingsRow>();
					if (catagoryGeneral.rows != null)
					{
						foreach (SettingsRow item6 in (Il2CppArrayBase<SettingsRow>)(object)catagoryGeneral.rows)
						{
							list3.Add(item6);
						}
					}
					list3.AddRange(list2);
					catagoryGeneral.rows = new Il2CppReferenceArray<SettingsRow>(list3.ToArray());
					val = log;
					if (val != null)
					{
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(57, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Placed ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list2.Count);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" mod row(s) inside General under the CROSSHAIR row");
						}
						val.LogInfo(val2);
					}
				}
			}
			catch (Exception ex)
			{
				val = log;
				if (val != null)
				{
					BepInExWarningLogInterpolatedStringHandler val8 = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("Placing rows in General failed: ");
						((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<string>(ex.Message);
					}
					val.LogWarning(val8);
				}
			}
			try
			{
				SettingsRow val9 = null;
				int num = -1;
				foreach (SettingsRow componentsInChild2 in ((Component)catagoryControls).GetComponentsInChildren<SettingsRow>(true))
				{
					if (!((Object)(object)componentsInChild2 == (Object)null))
					{
						int num2 = (int)componentsInChild2.settingsType switch
						{
							41 => 0, 
							42 => 1, 
							44 => 2, 
							43 => 3, 
							45 => 4, 
							_ => -1, 
						};
						if (num2 > num)
						{
							val9 = componentsInChild2;
							num = num2;
						}
					}
				}
				List<SettingsRow> list4 = new List<SettingsRow>();
				foreach (ModRowDef item7 in RowRegistry.Ordered())
				{
					if (item7.InControls)
					{
						Transform parent3;
						int siblingIndex3;
						if ((Object)(object)val9 != (Object)null)
						{
							parent3 = ((Component)val9).transform.parent;
							siblingIndex3 = ((Component)val9).transform.GetSiblingIndex() + 1 + list4.Count;
						}
						else
						{
							parent3 = parent;
							siblingIndex3 = siblingIndex + list.Count;
						}
						SettingsRow item2 = BuildRow(item7, parent3, siblingIndex3);
						if ((Object)(object)val9 == (Object)null)
						{
							list.Add(item2);
						}
						else
						{
							list4.Add(item2);
						}
					}
				}
				if (list4.Count > 0)
				{
					List<SettingsRow> list5 = new List<SettingsRow>();
					if (catagoryControls.rows != null)
					{
						foreach (SettingsRow item8 in (Il2CppArrayBase<SettingsRow>)(object)catagoryControls.rows)
						{
							list5.Add(item8);
						}
					}
					list5.AddRange(list4);
					catagoryControls.rows = new Il2CppReferenceArray<SettingsRow>(list5.ToArray());
					val = log;
					if (val != null)
					{
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(44, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Placed ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(list4.Count);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" mod row(s) inside Controls (anchor=");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)(object)val9 != (Object)null) ? ((O