Decompiled source of Practice Tools v1.0.0

PracticeTools.dll

Decompiled a month 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PracticeTools")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Practice Tools")]
[assembly: AssemblyTitle("PracticeTools")]
[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.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]
	[Microsoft.CodeAnalysis.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]
	[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 PracticeTools
{
	public class StoreValues
	{
		public static Vector3 PacmanPosition = Vector3.zero;
	}
	[HarmonyPatch(typeof(PacmanController))]
	internal class PatchesPacmanControllerClass
	{
		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void Postfix3()
		{
			//IL_0023: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0170: 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_0190: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.PluginConfig.Enabled.Value)
			{
				return;
			}
			bool key = PadManager.GetKey(0, Plugin.PluginConfig.QuickLevelResetPad.Value, true);
			bool key2 = KeyboardManager.GetKey(Plugin.PluginConfig.QuickLevelResetKeyboard.Value);
			bool key3 = PadManager.GetKey(0, Plugin.PluginConfig.QuickReturnToIslandPad.Value, true);
			bool key4 = KeyboardManager.GetKey(Plugin.PluginConfig.QuickReturnToIslandKeyboard.Value);
			bool key5 = PadManager.GetKey(0, Plugin.PluginConfig.SavePacmanPosPad.Value, true);
			bool key6 = KeyboardManager.GetKey(Plugin.PluginConfig.SavePacmanPosKeyboard.Value);
			bool key7 = PadManager.GetKey(0, Plugin.PluginConfig.LoadPacmanPosPad.Value, true);
			bool key8 = KeyboardManager.GetKey(Plugin.PluginConfig.LoadPacmanPosKeyboard.Value);
			bool flag = default(bool);
			if (key || key2)
			{
				SceneManager.ReloadScene((UnityAction<bool>)null, (EFadeKind)2, (EFadeKind)0, (ELoadUIKind)0);
			}
			else if (key4 || key3)
			{
				SingletonBase<StageScene>.Instance.OnEndStage((EScene)1, (ELoadUIKind)1, (EFadeKind)1);
			}
			else if (key5 || key6)
			{
				StoreValues.PacmanPosition = SingletonBase<PacmanController>.Instance.GetPosition();
				ManualLogSource log = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Stored position: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(StoreValues.PacmanPosition);
				}
				log.LogInfo(val);
			}
			else if (key7 || key8)
			{
				SingletonBase<PacmanController>.Instance.SetPositionImmediate(StoreValues.PacmanPosition, true, false);
				ManualLogSource log2 = Plugin.Log;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Loaded position...");
				}
				log2.LogInfo(val);
			}
		}
	}
	[BepInPlugin("PracticeTools", "Practice Tools", "1.0.0")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Log;

		internal static PluginConfig PluginConfig;

		public override void Load()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("PracticeTools");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			PluginConfig = new PluginConfig(((BasePlugin)this).Config);
			Harmony val2 = new Harmony("PracticeTools");
			val2.PatchAll();
		}
	}
	internal class PluginConfig
	{
		public ConfigFile Config;

		private FileSystemWatcher _watcher;

		internal ConfigEntry<bool> Enabled;

		internal ConfigEntry<EPadKeycode> SavePacmanPosPad;

		internal ConfigEntry<EPadKeycode> LoadPacmanPosPad;

		internal ConfigEntry<EPadKeycode> QuickLevelResetPad;

		internal ConfigEntry<EPadKeycode> QuickReturnToIslandPad;

		internal ConfigEntry<Key> SavePacmanPosKeyboard;

		internal ConfigEntry<Key> LoadPacmanPosKeyboard;

		internal ConfigEntry<Key> QuickLevelResetKeyboard;

		internal ConfigEntry<Key> QuickReturnToIslandKeyboard;

		public PluginConfig(ConfigFile config)
		{
			Config = config;
			Initialize();
			InitializeWatcher();
		}

		public void Initialize()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002d: Expected O, but got Unknown
			//IL_0043: 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_005e: Expected O, but got Unknown
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0090: Expected O, but got Unknown
			//IL_00a6: 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_00c2: Expected O, but got Unknown
			//IL_00c2: Expected O, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_00f4: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			//IL_0126: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_0158: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_018a: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01bc: Expected O, but got Unknown
			Enabled = Config.Bind<bool>(new ConfigDefinition("General", "Enabled"), true, new ConfigDescription("Enable plugin patches.", (AcceptableValueBase)null, Array.Empty<object>()));
			SavePacmanPosPad = Config.Bind<EPadKeycode>(new ConfigDefinition("PacmanPosition", "SavePacmanPosPad"), (EPadKeycode)8, new ConfigDescription("Pad button to save current pacman position.", (AcceptableValueBase)null, Array.Empty<object>()));
			LoadPacmanPosPad = Config.Bind<EPadKeycode>(new ConfigDefinition("PacmanPosition", "LoadPacmanPosPad"), (EPadKeycode)9, new ConfigDescription("Pad button to load stored pacmana position.", (AcceptableValueBase)null, Array.Empty<object>()));
			SavePacmanPosKeyboard = Config.Bind<Key>(new ConfigDefinition("PacmanPosition", "SavePacmanPosKeyboard"), (Key)41, new ConfigDescription("Keyboard button to save current pacman position.", (AcceptableValueBase)null, Array.Empty<object>()));
			LoadPacmanPosKeyboard = Config.Bind<Key>(new ConfigDefinition("PacmanPosition", "LoadPacmanPosKeyboard"), (Key)43, new ConfigDescription("Keyboard button to load current pacman position.", (AcceptableValueBase)null, Array.Empty<object>()));
			QuickLevelResetPad = Config.Bind<EPadKeycode>(new ConfigDefinition("LevelReset", "QuickLevelResetPad"), (EPadKeycode)14, new ConfigDescription("Pad button to reset level.", (AcceptableValueBase)null, Array.Empty<object>()));
			QuickReturnToIslandPad = Config.Bind<EPadKeycode>(new ConfigDefinition("LevelReset", "QuickReturnToIslandPad"), (EPadKeycode)15, new ConfigDescription("Pad button to perform return to island directly.", (AcceptableValueBase)null, Array.Empty<object>()));
			QuickLevelResetKeyboard = Config.Bind<Key>(new ConfigDefinition("LevelReset", "QuickLevelResetKeyboard"), (Key)45, new ConfigDescription("Keyboard button to reset level.", (AcceptableValueBase)null, Array.Empty<object>()));
			QuickReturnToIslandKeyboard = Config.Bind<Key>(new ConfigDefinition("LevelReset", "QuickReturnToIslandKeyboard"), (Key)47, new ConfigDescription("Keyboard button to perform return to island directly.", (AcceptableValueBase)null, Array.Empty<object>()));
		}

		public void InitializeWatcher()
		{
			_watcher = new FileSystemWatcher(Path.GetDirectoryName(Config.ConfigFilePath))
			{
				Filter = Path.GetFileName(Config.ConfigFilePath),
				NotifyFilter = (NotifyFilters.Size | NotifyFilters.LastWrite),
				IncludeSubdirectories = false
			};
			_watcher.Changed += delegate
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Expected O, but got Unknown
				RefreshConfig();
				ManualLogSource log = Plugin.Log;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(24, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("PracticeTools");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" config reloaded!");
				}
				log.LogInfo(val);
			};
			_watcher.EnableRaisingEvents = true;
		}

		public void RefreshConfig()
		{
			try
			{
				Config.Reload();
			}
			catch (Exception)
			{
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "PracticeTools";

		public const string PLUGIN_NAME = "Practice Tools";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}