Decompiled source of AccessibilityMod v1.1.0

AccessibilityMod/AccessibilityMod.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using GlobalSettings;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Silksong.ModMenu;
using Silksong.ModMenu.Elements;
using Silksong.ModMenu.Models;
using Silksong.ModMenu.Screens;
using TMProOld;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AccessibilityMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+ea8696e9b27a74acec194617b467250f72bededf")]
[assembly: AssemblyProduct("AccessibilityMod")]
[assembly: AssemblyTitle("AccessibilityMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AccessibilityMod
{
	internal static class AccessibilityConfig
	{
		internal const float NeutralPogoSpeedDefault = 0.25f;

		internal const float DiveDashSpeedDefault = 0.23f;

		internal const bool SpeedToggleHotkeyEnabledDefault = false;

		internal const KeyCode SpeedToggleHotkeyDefault = (KeyCode)0;

		internal static ConfigEntry<bool> ModEnabled;

		internal static ConfigEntry<float> NeutralPogoSpeed;

		internal static ConfigEntry<float> DiveDashSpeed;

		internal static ConfigEntry<bool> SpeedToggleHotkeyEnabled;

		internal static ConfigEntry<KeyCode> SpeedToggleHotkey;

		internal static void Bind(ConfigFile config)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			ModEnabled = config.Bind<bool>("General", "Enabled", true, "Master toggle for the Accessibility Mod.");
			NeutralPogoSpeed = config.Bind<float>("Speed", "Neutral Pogo Speed", 0.25f, new ConfigDescription("Speed boost applied to ground running before you have the dash ability (fraction added to run speed; 0 = off).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			DiveDashSpeed = config.Bind<float>("Speed", "Dive-dash Speed", 0.23f, new ConfigDescription("Speed boost applied while sprinting on the ground after you have the dash ability and the Hunter's Crest is equipped (0 = off).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			SpeedToggleHotkeyEnabled = config.Bind<bool>("Hotkey", "Speed Toggle Hotkey", false, "Enable a hotkey that temporarily turns the mod's speed boosts on and off.");
			SpeedToggleHotkey = config.Bind<KeyCode>("Hotkey", "Key", (KeyCode)0, "Key that toggles the speed boosts when the Speed Toggle Hotkey is enabled.");
		}
	}
	internal sealed class AccessibilityHud
	{
		private readonly struct Seg
		{
			internal readonly string Text;

			internal readonly string? Color;

			internal Seg(string text, string? color)
			{
				Text = text;
				Color = color;
			}
		}

		private readonly struct HudLine
		{
			internal readonly List<Seg> Segments;

			internal readonly float Scale;

			internal readonly float Alpha;

			internal HudLine(List<Seg> segments, float scale, float alpha)
			{
				Segments = segments;
				Scale = scale;
				Alpha = alpha;
			}
		}

		private const float FontSize = 40f;

		private const float PanelScale = 0.075f;

		private const float ToastScale = 0.115f;

		private const float LineGap = 0.12f;

		private const float RightAnchorX = 14.5f;

		private const float BottomAnchorY = -8.25f;

		private const float ToastSeconds = 4f;

		private const float ToastFadeSeconds = 1f;

		private const float AccentCropFraction = 0.12f;

		private const string Gold = "FFCC33";

		private const string Special = "66D0FF";

		private static readonly CultureInfo Inv = CultureInfo.InvariantCulture;

		private GameObject? root;

		private readonly List<TextMeshPro> pool = new List<TextMeshPro>();

		private readonly List<HudLine> lines = new List<HudLine>();

		private float toastUntil = -1f;

		private bool toastShowsDisabled;

		internal void ShowToast(bool speedsDisabled)
		{
			toastShowsDisabled = speedsDisabled;
			toastUntil = Time.unscaledTime + 4f + 1f;
		}

		internal void Tick()
		{
			if (!EnsureRoot())
			{
				return;
			}
			if (!AccessibilityConfig.ModEnabled.Value)
			{
				HideAll();
				return;
			}
			lines.Clear();
			if (IsPaused())
			{
				AddPanelLines();
			}
			float num = toastUntil - Time.unscaledTime;
			if (num > 0f)
			{
				float alpha = ((num < 1f) ? (num / 1f) : 1f);
				List<Seg> segments = new List<Seg>
				{
					new Seg("AccessibilityMod", "FFCC33"),
					new Seg(toastShowsDisabled ? " Speed Disabled" : " Speed Enabled", null)
				};
				lines.Add(new HudLine(segments, 0.115f, alpha));
			}
			Render();
		}

		private bool EnsureRoot()
		{
			if ((Object)(object)root != (Object)null)
			{
				return true;
			}
			pool.Clear();
			root = HudUI.CreateDisplayerRoot("AccessibilityModHud");
			return (Object)(object)root != (Object)null;
		}

		private void HideAll()
		{
			for (int i = 0; i < pool.Count; i++)
			{
				HudText.Hide(pool[i]);
			}
		}

		private static bool IsPaused()
		{
			GameManager instance = GameManager.instance;
			if ((Object)(object)instance != (Object)null)
			{
				return instance.IsGamePaused();
			}
			return false;
		}

		private void AddPanelLines()
		{
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			float value = AccessibilityConfig.NeutralPogoSpeed.Value;
			float value2 = AccessibilityConfig.DiveDashSpeed.Value;
			bool flag = Mathf.Abs(value - 0.25f) > 0.0001f;
			bool flag2 = Mathf.Abs(value2 - 0.23f) > 0.0001f;
			bool value3 = AccessibilityConfig.SpeedToggleHotkeyEnabled.Value;
			if (!flag && !flag2 && !value3)
			{
				lines.Add(new HudLine(new List<Seg>
				{
					new Seg("AccessibilityMod", "FFCC33"),
					new Seg(" set to ", null),
					new Seg("Default", "66D0FF"),
					new Seg(".", null)
				}, 0.075f, 1f));
				return;
			}
			lines.Add(new HudLine(new List<Seg>
			{
				new Seg("AccessibilityMod", "FFCC33")
			}, 0.075f, 1f));
			if (flag)
			{
				lines.Add(new HudLine(new List<Seg>
				{
					new Seg("NeutralPogoSpeed changed to ", null),
					new Seg(value.ToString("0.00", Inv), "66D0FF"),
					new Seg(".", null)
				}, 0.075f, 1f));
			}
			if (flag2)
			{
				lines.Add(new HudLine(new List<Seg>
				{
					new Seg("DivedashSpeed changed to ", null),
					new Seg(value2.ToString("0.00", Inv), "66D0FF"),
					new Seg(".", null)
				}, 0.075f, 1f));
			}
			if (value3)
			{
				KeyCode value4 = AccessibilityConfig.SpeedToggleHotkey.Value;
				lines.Add(new HudLine(new List<Seg>
				{
					new Seg("Speed Toggle Hotkey is ", null),
					new Seg("On", "66D0FF"),
					new Seg(((int)value4 == 0) ? "." : $" ({value4}).", null)
				}, 0.075f, 1f));
			}
		}

		private void Render()
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: 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_01a4: Unknown result type (might be due to invalid IL or missing references)
			while (pool.Count < lines.Count)
			{
				TextMeshPro val = HudText.TryCreate(root, "Line" + pool.Count);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				pool.Add(val);
			}
			for (int i = lines.Count; i < pool.Count; i++)
			{
				HudText.Hide(pool[i]);
			}
			float num = -8.25f;
			for (int num2 = lines.Count - 1; num2 >= 0; num2--)
			{
				HudLine hudLine = lines[num2];
				TextMeshPro val2 = pool[num2];
				((Component)val2).gameObject.SetActive(true);
				val2.transform.localScale = new Vector3(hudLine.Scale, hudLine.Scale, 1f);
				((TMP_Text)val2).fontSize = 40f;
				((TMP_Text)val2).richText = true;
				((Graphic)val2).color = new Color(1f, 1f, 1f, hudLine.Alpha);
				((TMP_Text)val2).text = BuildRich(hudLine.Segments, hudLine.Alpha);
				((TMP_Text)val2).ForceMeshUpdate();
				Bounds bounds = ((TMP_Text)val2).bounds;
				float num3 = 14.5f - ((Bounds)(ref bounds)).max.x * hudLine.Scale;
				float num4 = num - ((Bounds)(ref bounds)).min.y * hudLine.Scale;
				val2.transform.position = new Vector3(num3, num4, 0f);
				num += ((Bounds)(ref bounds)).size.y * hudLine.Scale + 0.12f;
				CropAccents(val2);
			}
		}

		private static string BuildRich(List<Seg> segments, float alpha)
		{
			string value = Mathf.Clamp(Mathf.RoundToInt(alpha * 255f), 0, 255).ToString("X2");
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Seg segment in segments)
			{
				string value2 = HudGlyphs.Fix(segment.Text);
				if (segment.Color != null)
				{
					stringBuilder.Append("<color=#").Append(segment.Color);
					if (alpha < 1f)
					{
						stringBuilder.Append(value);
					}
					stringBuilder.Append('>').Append(value2).Append("</color>");
				}
				else
				{
					stringBuilder.Append(value2);
				}
			}
			return stringBuilder.ToString();
		}

		private static bool IsAccented(char c)
		{
			if (c != 'Ò' && c != 'Ù')
			{
				return c == 'Ý';
			}
			return true;
		}

		private static void CropAccents(TextMeshPro text)
		{
			//IL_0033: 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_003a: 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_005a: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				TMP_TextInfo textInfo = ((TMP_Text)text).textInfo;
				if (textInfo == null || textInfo.characterCount == 0)
				{
					return;
				}
				float num = float.NegativeInfinity;
				float num2 = float.PositiveInfinity;
				for (int i = 0; i < textInfo.characterCount; i++)
				{
					TMP_CharacterInfo val = textInfo.characterInfo[i];
					if (val.isVisible && !IsAccented(val.character))
					{
						Vector3[] vertices = textInfo.meshInfo[val.materialReferenceIndex].vertices;
						int vertexIndex = val.vertexIndex;
						float num3 = Mathf.Max(vertices[vertexIndex + 1].y, vertices[vertexIndex + 2].y);
						float num4 = Mathf.Min(vertices[vertexIndex].y, vertices[vertexIndex + 3].y);
						if (num3 > num)
						{
							num = num3;
						}
						if (num4 < num2)
						{
							num2 = num4;
						}
					}
				}
				if (float.IsNegativeInfinity(num))
				{
					return;
				}
				float capY = ((num2 < num) ? (num - (num - num2) * 0.12f) : num);
				bool flag = false;
				for (int j = 0; j < textInfo.characterCount; j++)
				{
					TMP_CharacterInfo val2 = textInfo.characterInfo[j];
					if (val2.isVisible && IsAccented(val2.character))
					{
						TMP_MeshInfo val3 = textInfo.meshInfo[val2.materialReferenceIndex];
						int vertexIndex2 = val2.vertexIndex;
						ClampTop(val3.vertices, val3.uvs0, vertexIndex2, vertexIndex2 + 1, capY);
						ClampTop(val3.vertices, val3.uvs0, vertexIndex2 + 3, vertexIndex2 + 2, capY);
						flag = true;
					}
				}
				if (flag)
				{
					((TMP_Text)text).UpdateVertexData((TMP_VertexDataUpdateFlags)3);
				}
			}
			catch
			{
			}
		}

		private static void ClampTop(Vector3[] verts, Vector2[] uvs, int bottomIdx, int topIdx, float capY)
		{
			//IL_0049: 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_0089: 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)
			float y = verts[topIdx].y;
			float y2 = verts[bottomIdx].y;
			if (!(y <= capY) && !(y <= y2))
			{
				float num = (capY - y2) / (y - y2);
				verts[topIdx] = new Vector3(verts[topIdx].x, capY, verts[topIdx].z);
				uvs[topIdx] = new Vector2(uvs[topIdx].x, uvs[bottomIdx].y + num * (uvs[topIdx].y - uvs[bottomIdx].y));
			}
		}
	}
	internal static class AccessibilityModMenu
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static MenuElementGenerator <0>__BuildEntryButton;
		}

		private const float SliderStep = 0.01f;

		private const float SliderMax = 1f;

		internal static void Register()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			object obj = <>O.<0>__BuildEntryButton;
			if (obj == null)
			{
				MenuElementGenerator val = BuildEntryButton;
				<>O.<0>__BuildEntryButton = val;
				obj = (object)val;
			}
			Registry.AddModMenu("Accessibility Mod", (MenuElementGenerator)obj);
		}

		private static SelectableElement BuildEntryButton()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			TextButton val = new TextButton(LocalizedText.op_Implicit("Accessibility Mod"));
			AbstractMenuScreen screen = null;
			val.OnSubmit = (Action)Delegate.Combine(val.OnSubmit, (Action)delegate
			{
				if (screen == null)
				{
					screen = BuildScreen();
				}
				MenuScreenNavigation.Show(screen, (HistoryMode)0);
			});
			return (SelectableElement)val;
		}

		private static AbstractMenuScreen BuildScreen()
		{
			//IL_000b: 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_0111: 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_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_0249: Expected O, but got Unknown
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Expected O, but got Unknown
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Expected O, but got Unknown
			SimpleMenuScreen val = new SimpleMenuScreen("Accessibility Mod");
			List<float> steps = BuildSteps();
			ChoiceElement<bool> val2 = new ChoiceElement<bool>(LocalizedText.op_Implicit("Enabled"), (IChoiceModel<bool>)(object)ChoiceModels.ForBool("Off", "On"), LocalizedText.op_Implicit("Master toggle for the whole mod."))
			{
				Value = AccessibilityConfig.ModEnabled.Value
			};
			((SelectableValueElement<bool>)(object)val2).OnValueChanged += delegate(bool v)
			{
				AccessibilityConfig.ModEnabled.Value = v;
			};
			val.Add((MenuElement)(object)val2);
			ListSliderModel<float> pogoModel = new ListSliderModel<float>(steps)
			{
				DisplayFn = (int _, float v) => LocalizedText.op_Implicit(v.ToString("0.00", CultureInfo.InvariantCulture))
			};
			SliderElement<float> val3 = new SliderElement<float>(LocalizedText.op_Implicit("Neutral Pogo Speed"), (SliderModel<float>)(object)pogoModel);
			((SliderModel<float>)(object)pogoModel).Index = NearestIndex(steps, AccessibilityConfig.NeutralPogoSpeed.Value);
			((SelectableValueElement<float>)(object)val3).OnValueChanged += delegate(float v)
			{
				AccessibilityConfig.NeutralPogoSpeed.Value = v;
			};
			val.Add((MenuElement)(object)val3);
			ListSliderModel<float> diveModel = new ListSliderModel<float>(steps)
			{
				DisplayFn = (int _, float v) => LocalizedText.op_Implicit(v.ToString("0.00", CultureInfo.InvariantCulture))
			};
			SliderElement<float> val4 = new SliderElement<float>(LocalizedText.op_Implicit("Dive-dash Speed"), (SliderModel<float>)(object)diveModel);
			((SliderModel<float>)(object)diveModel).Index = NearestIndex(steps, AccessibilityConfig.DiveDashSpeed.Value);
			((SelectableValueElement<float>)(object)val4).OnValueChanged += delegate(float v)
			{
				AccessibilityConfig.DiveDashSpeed.Value = v;
			};
			val.Add((MenuElement)(object)val4);
			ChoiceElement<bool> hotkeyChoice = new ChoiceElement<bool>(LocalizedText.op_Implicit("Speed Toggle Hotkey"), (IChoiceModel<bool>)(object)ChoiceModels.ForBool("Off", "On"), LocalizedText.op_Implicit("Allows temporarily toggling the mod's speeds with the key below. (default: Off)"))
			{
				Value = AccessibilityConfig.SpeedToggleHotkeyEnabled.Value
			};
			((SelectableValueElement<bool>)(object)hotkeyChoice).OnValueChanged += delegate(bool v)
			{
				AccessibilityConfig.SpeedToggleHotkeyEnabled.Value = v;
			};
			val.Add((MenuElement)(object)hotkeyChoice);
			KeyBindElement val5 = new KeyBindElement(LocalizedText.op_Implicit("Key"));
			((SelectableValueElement<KeyCode>)val5).Value = AccessibilityConfig.SpeedToggleHotkey.Value;
			KeyBindElement keyElement = val5;
			((SelectableValueElement<KeyCode>)(object)keyElement).OnValueChanged += delegate(KeyCode v)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				AccessibilityConfig.SpeedToggleHotkey.Value = v;
			};
			val.Add((MenuElement)(object)keyElement);
			TextButton val6 = new TextButton(LocalizedText.op_Implicit("Set to Default"));
			val6.OnSubmit = (Action)Delegate.Combine(val6.OnSubmit, (Action)delegate
			{
				AccessibilityConfig.NeutralPogoSpeed.Value = 0.25f;
				AccessibilityConfig.DiveDashSpeed.Value = 0.23f;
				AccessibilityConfig.SpeedToggleHotkeyEnabled.Value = false;
				AccessibilityConfig.SpeedToggleHotkey.Value = (KeyCode)0;
				((SliderModel<float>)(object)pogoModel).Index = NearestIndex(steps, 0.25f);
				((SliderModel<float>)(object)diveModel).Index = NearestIndex(steps, 0.23f);
				((SelectableValueElement<bool>)(object)hotkeyChoice).Value = false;
				((SelectableValueElement<KeyCode>)(object)keyElement).Value = (KeyCode)0;
			});
			val.Add((MenuElement)(object)val6);
			return (AbstractMenuScreen)val;
		}

		private static List<float> BuildSteps()
		{
			int num = (int)Math.Round(100.0) + 1;
			List<float> list = new List<float>(num);
			for (int i = 0; i < num; i++)
			{
				list.Add((float)Math.Round((float)i * 0.01f, 2));
			}
			return list;
		}

		private static int NearestIndex(List<float> steps, float value)
		{
			int result = 0;
			float num = float.MaxValue;
			for (int i = 0; i < steps.Count; i++)
			{
				float num2 = Math.Abs(steps[i] - value);
				if (num2 < num)
				{
					num = num2;
					result = i;
				}
			}
			return result;
		}
	}
	[BepInPlugin("fireb0rn.AccessibilityMod", "Accessibility Mod", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[ModMenuIgnore]
	public class AccessibilityPlugin : BaseUnityPlugin
	{
		internal const string PluginGuid = "fireb0rn.AccessibilityMod";

		internal const string PluginName = "Accessibility Mod";

		internal const string PluginVersion = "1.1.0";

		private const string ModMenuGuid = "org.silksong-modding.modmenu";

		private AccessibilityHud? hud;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			AccessibilityConfig.Bind(((BaseUnityPlugin)this).Config);
			new Harmony("fireb0rn.AccessibilityMod").PatchAll();
			hud = new AccessibilityHud();
			TryRegisterModMenu();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Accessibility Mod 1.1.0 loaded.");
		}

		private void Update()
		{
			HandleSpeedToggleHotkey();
			hud?.Tick();
		}

		private void HandleSpeedToggleHotkey()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!AccessibilityConfig.ModEnabled.Value)
			{
				AccessibilityRuntime.SpeedsTemporarilyDisabled = false;
				return;
			}
			if (!AccessibilityConfig.SpeedToggleHotkeyEnabled.Value)
			{
				AccessibilityRuntime.SpeedsTemporarilyDisabled = false;
				return;
			}
			KeyCode value = AccessibilityConfig.SpeedToggleHotkey.Value;
			if ((int)value != 0 && Input.GetKeyDown(value))
			{
				AccessibilityRuntime.SpeedsTemporarilyDisabled = !AccessibilityRuntime.SpeedsTemporarilyDisabled;
				hud?.ShowToast(AccessibilityRuntime.SpeedsTemporarilyDisabled);
			}
		}

		private void TryRegisterModMenu()
		{
			if (!Chainloader.PluginInfos.ContainsKey("org.silksong-modding.modmenu"))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Silksong.ModMenu not installed; the in-game Mod Menu is unavailable (settings remain editable in BepInEx/config).");
				return;
			}
			try
			{
				RegisterModMenu();
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"Failed to register the Mod Menu: {arg}");
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static void RegisterModMenu()
		{
			AccessibilityModMenu.Register();
		}
	}
	internal static class AccessibilityRuntime
	{
		internal static bool SpeedsTemporarilyDisabled;
	}
	[HarmonyPatch(typeof(HeroController), "FixedUpdate")]
	internal static class DiveDashSpeedEffect
	{
		private const float SprintSpeedRatio = 2.121212f;

		private static bool IsEnabled
		{
			get
			{
				if (AccessibilityConfig.ModEnabled.Value && !AccessibilityRuntime.SpeedsTemporarilyDisabled && PlayerData.instance != null && PlayerData.instance.hasDash)
				{
					return IsHunterCrestEquipped;
				}
				return false;
			}
		}

		private static bool IsHunterCrestEquipped
		{
			get
			{
				ToolCrest hunterCrest = Gameplay.HunterCrest;
				ToolCrest hunterCrest2 = Gameplay.HunterCrest2;
				ToolCrest hunterCrest3 = Gameplay.HunterCrest3;
				if ((!((Object)(object)hunterCrest != (Object)null) || !((ToolBase)hunterCrest).IsEquipped) && (!((Object)(object)hunterCrest2 != (Object)null) || !((ToolBase)hunterCrest2).IsEquipped))
				{
					if ((Object)(object)hunterCrest3 != (Object)null)
					{
						return ((ToolBase)hunterCrest3).IsEquipped;
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPostfix]
		private static void BoostSprintSpeed(HeroController __instance)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0110: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			if (!IsEnabled || !__instance.cState.isSprinting || !__instance.cState.onGround || __instance.cState.downAttacking || __instance.cState.isBinding || __instance.IsSprintMasterActive || __instance.IsUsingQuickening)
			{
				return;
			}
			Rigidbody2D rb2d = __instance.rb2d;
			if ((Object)(object)rb2d == (Object)null)
			{
				return;
			}
			Vector2 linearVelocity = rb2d.linearVelocity;
			float num = Mathf.Abs(linearVelocity.x);
			if (!(num <= 0f))
			{
				float value = AccessibilityConfig.DiveDashSpeed.Value;
				if (linearVelocity.x > 0f == __instance.cState.facingRight && !__instance.cState.dashing && num < __instance.DASH_SPEED)
				{
					float num2 = __instance.RUN_SPEED * value;
					linearVelocity.x += Mathf.Sign(linearVelocity.x) * num2;
					num = Mathf.Abs(linearVelocity.x);
				}
				float num3 = __instance.RUN_SPEED * (2.121212f + value);
				if (num > num3)
				{
					linearVelocity.x = Mathf.Sign(linearVelocity.x) * num3;
				}
				rb2d.linearVelocity = linearVelocity;
			}
		}
	}
	internal static class HudFonts
	{
		internal static readonly Lazy<TMP_FontAsset> Trajan = new Lazy<TMP_FontAsset>((Func<TMP_FontAsset>)(() => Resources.FindObjectsOfTypeAll<TMP_FontAsset>().First((TMP_FontAsset f) => ((Object)f).name == "trajan_bold_tmpro")));
	}
	internal static class HudGlyphs
	{
		internal static string Fix(string s)
		{
			if (!string.IsNullOrEmpty(s))
			{
				return s.ToUpperInvariant().Replace('O', 'Ò').Replace('U', 'Ù')
					.Replace('Y', 'Ý');
			}
			return s;
		}
	}
	internal static class HudText
	{
		private static readonly Vector2 InactivePosition = new Vector2(-1000f, -1000f);

		private const string HudSortingLayer = "HUD";

		private const int HudSortingOrder = 11;

		internal static TextMeshPro? TryCreate(GameObject parent, string name)
		{
			//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_000e: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = 5
			};
			val.transform.SetParent(parent.transform);
			TextMeshPro val2;
			try
			{
				val2 = val.AddComponent<TextMeshPro>();
				((TMP_Text)val2).font = HudFonts.Trajan.Value;
			}
			catch
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			((Graphic)val2).color = Color.white;
			((TMP_Text)val2).enableWordWrapping = false;
			((TMP_Text)val2).autoSizeTextContainer = true;
			MeshRenderer component = val.GetComponent<MeshRenderer>();
			((Renderer)component).sortingLayerName = "HUD";
			((Renderer)component).sortingOrder = 11;
			val.SetActive(false);
			return val2;
		}

		internal static void Hide(TextMeshPro? text)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)text == (Object)null))
			{
				((Component)text).gameObject.SetActive(false);
				text.transform.position = Vector2.op_Implicit(InactivePosition);
			}
		}
	}
	internal static class HudUI
	{
		private const string HudCameraParentPath = "_GameCameras/HudCamera/In-game";

		private static bool TryGetHudCameraParent(out GameObject parent)
		{
			parent = GameObject.Find("_GameCameras/HudCamera/In-game");
			return (Object)(object)parent != (Object)null;
		}

		internal static GameObject? CreateDisplayerRoot(string name)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			if (!TryGetHudCameraParent(out GameObject parent))
			{
				return null;
			}
			GameObject val = new GameObject(name)
			{
				layer = 5
			};
			Object.DontDestroyOnLoad((Object)val);
			val.transform.SetParent(parent.transform);
			val.transform.localPosition = Vector3.zero;
			return val;
		}
	}
	[AttributeUsage(AttributeTargets.Class)]
	internal sealed class ModMenuIgnoreAttribute : Attribute
	{
	}
	[HarmonyPatch(typeof(HeroController), "Move")]
	internal static class NeutralPogoSpeedEffect
	{
		private static bool IsEnabled
		{
			get
			{
				if (AccessibilityConfig.ModEnabled.Value && !AccessibilityRuntime.SpeedsTemporarilyDisabled && PlayerData.instance != null)
				{
					return !PlayerData.instance.hasDash;
				}
				return false;
			}
		}

		private static bool IsPogoing(HeroController hc)
		{
			HeroControllerStates cState = hc.cState;
			if (!cState.downAttacking && !cState.downSpiking && !cState.downSpikeAntic && !cState.downSpikeBouncing && !cState.downSpikeBouncingShort && !cState.downSpikeRecovery && !cState.bouncing)
			{
				return cState.recoilingDrill;
			}
			return true;
		}

		[HarmonyPostfix]
		private static void BoostRunSpeed(HeroController __instance, bool useInput)
		{
			//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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (!IsEnabled || !useInput || __instance.cState.wallSliding || !__instance.cState.onGround || __instance.cState.isSprinting || __instance.cState.dashing || __instance.cState.isBinding || IsPogoing(__instance) || __instance.IsUsingQuickening)
			{
				return;
			}
			Rigidbody2D rb2d = __instance.rb2d;
			if (!((Object)(object)rb2d == (Object)null))
			{
				float value = AccessibilityConfig.NeutralPogoSpeed.Value;
				Vector2 linearVelocity = rb2d.linearVelocity;
				if (Mathf.Abs(linearVelocity.x) > 0f)
				{
					linearVelocity.x *= 1f + value;
				}
				float num = __instance.RUN_SPEED * (1f + value);
				if (Mathf.Abs(linearVelocity.x) > num)
				{
					linearVelocity.x = Mathf.Sign(linearVelocity.x) * num;
				}
				rb2d.linearVelocity = linearVelocity;
			}
		}
	}
}