Decompiled source of SimpleUnlocker v1.1.0

SimpleUnlocker.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("SimpleUnlocker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimpleUnlocker")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("BB306404-6D08-43A2-8168-C0E6F38E1799")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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 SimpleUnlocker
{
	[BepInPlugin("club.freewifi.void.SimpleUnlocker", "SimpleUnlocker", "1.1.0")]
	public class SimpleUnlocker : BaseUnityPlugin
	{
		public enum SashColor
		{
			Default = -1,
			Blue,
			Green,
			LightGreen,
			Black,
			Brown,
			Red,
			Purple,
			Silver,
			Gold
		}

		private const string ModGUID = "club.freewifi.void.SimpleUnlocker";

		private const string ModName = "SimpleUnlocker";

		private const string ModVersion = "1.1.0";

		public static ConfigEntry<bool> UnlockCosmetics;

		public static ConfigEntry<bool> UnlockAscents;

		private void Awake()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			UnlockCosmetics = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Unlock Cosmetics", true, "Unlocks all Cosmetics within the game.");
			UnlockAscents = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Unlock Ascents", false, "Unlocks all Ascents within the game.");
			new Harmony("club.freewifi.void.SimpleUnlocker").PatchAll();
		}
	}
}
namespace SimpleUnlocker.Patches
{
	[HarmonyPatch(typeof(BoardingPass), "UpdateAscent")]
	public static class UnlockAscents
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			val.MatchStartForward((CodeMatch[])(object)new CodeMatch[4]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(AchievementManager), "Instance"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(AchievementManager), "GetMaxAscent", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(BoardingPass), "maxUnlockedAscent"), (string)null)
			});
			if (val.ReportFailure((MethodBase)null, (Action<string>)Debug.LogError))
			{
				throw new Exception();
			}
			val.RemoveInstructions(4);
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(UnlockAscents), "SetUnlockedAscents", (Type[])null, (Type[])null))
			});
			return val.Instructions();
		}

		private static void SetUnlockedAscents(BoardingPass boardingPass)
		{
			if (!SimpleUnlocker.UnlockAscents.Value)
			{
				boardingPass.maxUnlockedAscent = Singleton<AchievementManager>.Instance.GetMaxAscent();
			}
			else
			{
				boardingPass.maxUnlockedAscent = boardingPass.maxAscent + 1;
			}
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	public class UnlockCosmetics
	{
		public static bool Prefix(CustomizationOption __instance, ref bool __result)
		{
			if (!SimpleUnlocker.UnlockCosmetics.Value)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}