Decompiled source of AbyssJumpers v1.0.3

BepInEx/plugins/ILectriq-AbyssJumpers/AbyssJumpers.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace AbyssJumpers;

[BepInPlugin("ILectriq.AbyssJumpers", "Abyss Jumpers", "1.0.0")]
public sealed class AbyssJumpersPlugin : BasePlugin
{
	public sealed class JumpController : MonoBehaviour
	{
		private const float MatchTolerance = 0.0001f;

		private const float NotificationDuration = 2.5f;

		private float baselineJumpHeight = float.NaN;

		private float lastAppliedJumpHeight = float.NaN;

		private bool modEnabled;

		private string notificationText = "";

		private float notificationTimer;

		private GUIStyle labelStyle;

		public JumpController(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Update()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(ToggleKey))
			{
				modEnabled = !modEnabled;
				ShowNotification("Abyss Jumpers: " + (modEnabled ? "ON" : "OFF"));
			}
			if (Input.GetKeyDown(IncreaseKey))
			{
				AdjustMultiplier(MultiplierStep.Value);
			}
			if (Input.GetKeyDown(DecreaseKey))
			{
				AdjustMultiplier(0f - MultiplierStep.Value);
			}
			if (Input.GetKeyDown(ResetKey))
			{
				ResetMultiplier();
			}
			if (notificationTimer > 0f)
			{
				notificationTimer -= Time.deltaTime;
			}
			GameplayControls instance = GameplayControls.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				baselineJumpHeight = float.NaN;
				lastAppliedJumpHeight = float.NaN;
				return;
			}
			float jumpHeight = instance.jumpHeight;
			if (float.IsNaN(lastAppliedJumpHeight) || !(Math.Abs(jumpHeight - lastAppliedJumpHeight) <= 0.0001f) || float.IsNaN(baselineJumpHeight))
			{
				baselineJumpHeight = jumpHeight;
			}
			float num = (modEnabled ? (baselineJumpHeight * JumpMultiplier.Value) : baselineJumpHeight);
			if (Math.Abs(jumpHeight - num) > 0.0001f)
			{
				instance.jumpHeight = num;
			}
			lastAppliedJumpHeight = num;
		}

		private void EnsureStyle()
		{
			//IL_0035: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (labelStyle == null)
			{
				Font font = Font.CreateDynamicFontFromOSFont(Il2CppStringArray.op_Implicit(new string[3] { "Consolas", "Courier New", "Lucida Console" }), 16);
				labelStyle = new GUIStyle
				{
					font = font,
					fontSize = 16,
					alignment = (TextAnchor)3
				};
				labelStyle.normal.textColor = new Color(0.8235294f, 41f / 51f, 76f / 85f);
			}
		}

		public void OnGUI()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if (!(notificationTimer <= 0f))
			{
				EnsureStyle();
				float num = (float)Screen.height - 24f - 55f;
				GUIStyle val = new GUIStyle(labelStyle);
				val.normal.textColor = new Color(0f, 0f, 0f, 0.8f);
				GUI.Label(new Rect(12f + 1f, num + 1f, 300f, 24f), notificationText, val);
				GUI.Label(new Rect(12f, num, 300f, 24f), notificationText, labelStyle);
			}
		}

		private void AdjustMultiplier(float delta)
		{
			float value = Mathf.Clamp(JumpMultiplier.Value + delta, 0.1f, 10f);
			JumpMultiplier.Value = value;
			ShowNotification($"Jump Multiplier: {value:0.00}");
		}

		private void ResetMultiplier()
		{
			JumpMultiplier.Value = 1.5f;
			ShowNotification($"Jump Multiplier: {1.5f:0.00} (reset)");
		}

		private void ShowNotification(string text)
		{
			notificationText = text;
			notificationTimer = 2.5f;
		}
	}

	internal const string PluginGuid = "ILectriq.AbyssJumpers";

	internal const string PluginName = "Abyss Jumpers";

	internal const string PluginVersion = "1.0.0";

	internal const float MinMultiplier = 0.1f;

	internal const float MaxMultiplier = 10f;

	internal const float DefaultMultiplier = 1.5f;

	private const string KeyNameHint = "Key name. See Unity's key name reference for valid values: https://docs.unity3d.com/ScriptReference/KeyCode.html - Restart required to change.";

	internal static ConfigEntry<float> JumpMultiplier;

	internal static ConfigEntry<float> MultiplierStep;

	internal static ManualLogSource Logger;

	internal static KeyCode ToggleKey;

	internal static KeyCode IncreaseKey;

	internal static KeyCode DecreaseKey;

	internal static KeyCode ResetKey;

	public override void Load()
	{
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Expected O, but got Unknown
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Expected O, but got Unknown
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		Logger = ((BasePlugin)this).Log;
		JumpMultiplier = ((BasePlugin)this).Config.Bind<float>("General", "JumpMultiplier", 1.5f, new ConfigDescription("Multiplies the game's normal jump height when Abyss Jumpers mode is on. 1.0 = vanilla, " + $"2.0 = twice as high, 0.5 = half as high. Values from {0.1f} to {10f} are allowed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		MultiplierStep = ((BasePlugin)this).Config.Bind<float>("General", "MultiplierStep", 0.1f, "How much the increase/decrease keys change JumpMultiplier by, per press.");
		ConfigEntry<string> val = ((BasePlugin)this).Config.Bind<string>("Keybinds", "ToggleKey", "F1", "Toggles Abyss Jumpers mode on/off while playing. Key name. See Unity's key name reference for valid values: https://docs.unity3d.com/ScriptReference/KeyCode.html - Restart required to change.");
		ConfigEntry<string> val2 = ((BasePlugin)this).Config.Bind<string>("Keybinds", "IncreaseKey", "PageUp", "Increases JumpMultiplier by MultiplierStep each press. Key name. See Unity's key name reference for valid values: https://docs.unity3d.com/ScriptReference/KeyCode.html - Restart required to change.");
		ConfigEntry<string> val3 = ((BasePlugin)this).Config.Bind<string>("Keybinds", "DecreaseKey", "PageDown", "Decreases JumpMultiplier by MultiplierStep each press. Key name. See Unity's key name reference for valid values: https://docs.unity3d.com/ScriptReference/KeyCode.html - Restart required to change.");
		ConfigEntry<string> obj = ((BasePlugin)this).Config.Bind<string>("Keybinds", "ResetKey", "Home", $"Resets JumpMultiplier back to {1.5f} while playing. " + "Key name. See Unity's key name reference for valid values: https://docs.unity3d.com/ScriptReference/KeyCode.html - Restart required to change.");
		ToggleKey = ParseKey(val.Value, (KeyCode)282, "ToggleKey");
		IncreaseKey = ParseKey(val2.Value, (KeyCode)280, "IncreaseKey");
		DecreaseKey = ParseKey(val3.Value, (KeyCode)281, "DecreaseKey");
		ResetKey = ParseKey(obj.Value, (KeyCode)278, "ResetKey");
		((BasePlugin)this).AddComponent<JumpController>();
		ManualLogSource log = ((BasePlugin)this).Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(42, 4, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("Abyss Jumpers");
			((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" v");
			((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>("1.0.0");
			((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" loaded. Jump multiplier: ");
			((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<float>(JumpMultiplier.Value, "0.0");
			((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", toggle key: ");
			((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<KeyCode>(ToggleKey);
		}
		log.LogInfo(val4);
	}

	private static KeyCode ParseKey(string raw, KeyCode fallback, string settingName)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_000b: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		if (Enum.TryParse<KeyCode>(raw, ignoreCase: true, out KeyCode result))
		{
			return result;
		}
		ManualLogSource logger = Logger;
		bool flag = default(bool);
		BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 3, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(raw);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' isn't a recognized key name for ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(settingName);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", falling back to ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<KeyCode>(fallback);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
		}
		logger.LogWarning(val);
		return fallback;
	}
}