Decompiled source of UnlockEverything v1.0.0

UnlockEverything.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts.Saves___Serialization.Progression.Achievements;
using Assets.Scripts.Saves___Serialization.Progression.Unlocks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("UnlockEverything")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Unlock all content in Megabonk")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+17700b277cc95a927c91fe288f653b79e2914ea0")]
[assembly: AssemblyProduct("UnlockEverything")]
[assembly: AssemblyTitle("UnlockEverything")]
[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 unlockEverything
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "UnlockEverything";

		public const string PLUGIN_NAME = "UnlockEverything";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace UnlockEverything
{
	[BepInPlugin("com.megabonk.unlockeverything", "Unlock Everything", "1.0.0")]
	public class Plugin : BasePlugin
	{
		private static class UnlockPatches
		{
			[HarmonyPrefix]
			[HarmonyPatch(typeof(MyAchievements), "IsAvailable")]
			public static bool IsAvailable_Prefix(UnlockableBase unlockable, ref bool __result)
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Expected O, but got Unknown
				if (!unlockAllEnabled.Value)
				{
					return true;
				}
				if (debugLogging.Value && (Object)(object)unlockable != (Object)null)
				{
					try
					{
						string name = unlockable.GetName();
						ManualLogSource logger = Logger;
						bool flag = default(bool);
						BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Unlocking: ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
						}
						logger.LogInfo(val);
					}
					catch
					{
					}
				}
				__result = true;
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(MyAchievements), "IsPurchased")]
			public static bool IsPurchased_Prefix(UnlockableBase unlockable, ref bool __result)
			{
				if (!unlockAllEnabled.Value)
				{
					return true;
				}
				__result = true;
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(MyAchievements), "IsAchievementDone", new Type[] { typeof(string) })]
			public static bool IsAchievementDone_Prefix(string achName, ref bool __result)
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				if (!unlockAllEnabled.Value)
				{
					return true;
				}
				if (debugLogging.Value && !string.IsNullOrEmpty(achName))
				{
					ManualLogSource logger = Logger;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Unlocking achievement: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(achName);
					}
					logger.LogInfo(val);
				}
				__result = true;
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(CharacterData), "IsBlackedOutInCharacterSelectionScreen")]
			public static bool IsBlackedOutInCharacterSelectionScreen_Prefix(ref bool __result)
			{
				if (!unlockAllEnabled.Value)
				{
					return true;
				}
				__result = false;
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(MyAchievements), "IsUnlocked", new Type[] { typeof(MyAchievement) })]
			public static bool IsUnlocked_MyAchievement_Prefix(MyAchievement myAchievement, ref bool __result)
			{
				if (!unlockAllEnabled.Value)
				{
					return true;
				}
				__result = true;
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(UnlockableBase), "CanBuy")]
			public static bool CanBuy_Prefix(ref bool __result)
			{
				if (!unlockAllEnabled.Value)
				{
					return true;
				}
				__result = true;
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(ChallengeData), "CanShow")]
			public static bool CanShow_Prefix(ref bool __result)
			{
				if (!unlockAllEnabled.Value)
				{
					return true;
				}
				__result = true;
				return false;
			}
		}

		internal static ManualLogSource Logger;

		private static ConfigEntry<bool> unlockAllEnabled;

		private static ConfigEntry<bool> debugLogging;

		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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			Logger = ((BasePlugin)this).Log;
			ManualLogSource logger = Logger;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("com.megabonk.unlockeverything");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loading!");
			}
			logger.LogInfo(val);
			unlockAllEnabled = ((BasePlugin)this).Config.Bind<bool>("General", "UnlockAllEnabled", true, "Enable/disable unlocking all content");
			debugLogging = ((BasePlugin)this).Config.Bind<bool>("Debug", "DebugLogging", false, "Enable debug logging for unlock checks");
			try
			{
				Harmony.CreateAndPatchAll(typeof(UnlockPatches), (string)null);
				ManualLogSource logger2 = Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(36, 0, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Successfully patched unlock methods!");
				}
				logger2.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource logger3 = Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to apply patches: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				logger3.LogError(val2);
				ManualLogSource logger4 = Logger;
				val2 = new BepInExErrorLogInterpolatedStringHandler(13, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Stack trace: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.StackTrace);
				}
				logger4.LogError(val2);
			}
			ManualLogSource logger5 = Logger;
			val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("com.megabonk.unlockeverything");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			logger5.LogInfo(val);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.megabonk.unlockeverything";

		public const string PLUGIN_NAME = "Unlock Everything";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}