Decompiled source of TootTallyWickedCursorMovement v1.0.0

plugins/TootTallyWickedCursorMovement.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BaboonAPI.Hooks.Initializer;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TootTallyCore;
using TootTallyCore.Graphics.Animations;
using TootTallyCore.Utils.TootTallyModules;
using TootTallySettings;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TootTallyWickedCursorMovement")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("For people that are getting too good at the game")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TootTallyWickedCursorMovement")]
[assembly: AssemblyTitle("TootTallyWickedCursorMovement")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TootTallyWickedCursorMovement
{
	[BepInPlugin("TootTallyWickedCursorMovement", "TootTallyWickedCursorMovement", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin, ITootTallyModule
	{
		public static class WickedCursorPatches
		{
			public static SecondDegreeDynamicsAnimation cursorDynamics;

			public static Vector2 cursorPosition;

			public static Vector2 cursorDestination;

			[HarmonyPatch(typeof(GameController), "Start")]
			[HarmonyPostfix]
			public static void GameControllerStartPostfixPatch(GameController __instance)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Expected O, but got Unknown
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				cursorDynamics = new SecondDegreeDynamicsAnimation(Instance.Frequency.Value, Instance.Damping.Value, Instance.InitialResponse.Value);
				cursorPosition = Vector2.op_Implicit(__instance.pointer.transform.localPosition);
				cursorDynamics.SetStartVector(Vector2.op_Implicit(cursorPosition));
			}

			[HarmonyPatch(typeof(GameController), "Update")]
			[HarmonyPrefix]
			public static void GameControllerUpdatePostfixPatch(GameController __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: 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_0063: Unknown result type (might be due to invalid IL or missing references)
				cursorDestination = Vector2.op_Implicit(Input.mousePosition / 2.42f);
				cursorDestination.y -= 220f;
				if (cursorDynamics != null && cursorPosition != cursorDestination)
				{
					cursorPosition.y = cursorDynamics.GetNewVector(Vector2.op_Implicit(cursorDestination), Time.deltaTime).y;
				}
				__instance.pointer.transform.localPosition = Vector2.op_Implicit(cursorPosition);
			}
		}

		public static Plugin Instance;

		private const string CONFIG_NAME = "WickedCursorMovement.cfg";

		private const string CONFIG_FIELD = "WickedCursorMovement";

		private const float DEFAULT_FREQ = 3.5f;

		private const float DEFAULT_DAMP = 0.12f;

		private const float DEFAULT_INIT = 1.5f;

		private Harmony _harmony;

		public static TootTallySettingPage settingPage;

		public ConfigEntry<bool> ModuleConfigEnabled { get; set; }

		public bool IsConfigInitialized { get; set; }

		public string Name
		{
			get
			{
				return "WickedCursorMovement";
			}
			set
			{
				Name = value;
			}
		}

		public ConfigEntry<float> Frequency { get; set; }

		public ConfigEntry<float> Damping { get; set; }

		public ConfigEntry<float> InitialResponse { get; set; }

		public static void LogInfo(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}

		public static void LogError(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogError((object)msg);
		}

		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				Instance = this;
				_harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				GameInitializationEvent.Register(((BaseUnityPlugin)this).Info, (Action)TryInitialize);
			}
		}

		private void TryInitialize()
		{
			ModuleConfigEnabled = ((BaseUnityPlugin)Plugin.Instance).Config.Bind<bool>("Modules", "Wicked Cursor Movement", true, "For the people that are getting too good at the game");
			TootTallyModuleManager.AddModule((ITootTallyModule)(object)this);
			Plugin.Instance.AddModuleToSettingPage((ITootTallyModule)(object)this);
		}

		public void LoadModule()
		{
			//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_002b: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Paths.BepInExRootPath, "config/");
			ConfigFile val = new ConfigFile(text + "WickedCursorMovement.cfg", true)
			{
				SaveOnConfigSet = true
			};
			Frequency = val.Bind<float>("WickedCursorMovement", "Frequency", 3.5f, "The strenght of the vibration (Higher vibrates more).");
			Damping = val.Bind<float>("WickedCursorMovement", "Damping", 0.12f, "How fast the cursor settle at the original target.\n(0 will vibrate forever, 100 will not vibrate).");
			InitialResponse = val.Bind<float>("WickedCursorMovement", "InitialResponse", 1.5f, "How much it anticipates the motion.\n(value higher than one will take time to accelerate, value lower than 0 will ancitipate the motion).");
			settingPage = TootTallySettingsManager.AddNewPage("WickedCursor\nMovementV2", "Wicked Cursor", 40f, new Color(0f, 0f, 0f, 0f));
			TootTallySettingPage obj = settingPage;
			if (obj != null)
			{
				obj.AddSlider("Frequency", 0.01f, 10f, Frequency, false);
			}
			TootTallySettingPage obj2 = settingPage;
			if (obj2 != null)
			{
				obj2.AddSlider("Damping", 0f, 10f, Damping, false);
			}
			TootTallySettingPage obj3 = settingPage;
			if (obj3 != null)
			{
				obj3.AddSlider("Initial Response", -10f, 10f, InitialResponse, false);
			}
			settingPage.AddLabel($"Some good default values are:\nFreq: {3.5f}\nDamp: {0.12f}\nInit: {1.5f}", (FontStyles)0, (TextAlignmentOptions)4097);
			settingPage.AddLabel("To turn off the effect, go to the TootTally Module's page and turn off the module.", (FontStyles)0, (TextAlignmentOptions)4097);
			Plugin.TryAddThunderstoreIconToPageButton(((BaseUnityPlugin)Instance).Info.Location, Name, settingPage);
			_harmony.PatchAll(typeof(WickedCursorPatches));
			LogInfo("Module loaded!");
		}

		public void UnloadModule()
		{
			_harmony.UnpatchSelf();
			settingPage.Remove();
			LogInfo("Module unloaded!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "TootTallyWickedCursorMovement";

		public const string PLUGIN_NAME = "TootTallyWickedCursorMovement";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}