Decompiled source of ResettableUnlocks v1.0.1

BepInEx/plugins/ResettableUnlocks/ResettableUnlocks.dll

Decompiled 2 weeks 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 BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ResettableUnlocks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("ResettableUnlocks")]
[assembly: AssemblyTitle("ResettableUnlocks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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;
		}
	}
}
[BepInPlugin("com.fizzy.resettableunlocks", "ResettableUnlocks", "1.0.1")]
public class LockSlotsMod : BaseUnityPlugin
{
	public const string PluginGUID = "com.fizzy.resettableunlocks";

	public const string PluginName = "ResettableUnlocks";

	public const string PluginVersion = "1.0.1";

	private readonly Harmony harmony = new Harmony("com.fizzy.resettableunlocks");

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Resettable Unlocks Mod loaded!");
		harmony.PatchAll();
	}
}
[HarmonyPatch(typeof(UIActivateGirlSlot), "OnPointerDown")]
public static class UIActivateGirlSlotOnPointerDownPatch
{
	private static bool Prefix(UIActivateGirlSlot __instance, PointerEventData eventData)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Invalid comparison between Unknown and I4
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		if (__instance.IsActivated && (int)__instance.Config.specialType != 5)
		{
			DataMgr.selectedWorldData.activateGirlActivatedIDs2.Remove(__instance.ID);
			StringHelper.PlaySE(SEMgr.Inst.uiClick, (SEPlayMode)0, 3, 0.05f);
			FieldInfo fieldInfo = AccessTools.Field(typeof(UIActivateGirlSlot), "uiActivateGirl");
			UIActivateGirl val = (UIActivateGirl)fieldInfo.GetValue(__instance);
			if (val.ActivateCount > 0)
			{
				PropertyInfo propertyInfo = AccessTools.Property(typeof(UIActivateGirl), "ActivateCount");
				int activateCount = val.ActivateCount;
				propertyInfo.SetValue(val, activateCount - 1);
			}
			PlayerMgr.Inst.ChangeChaosCore(__instance.Config.cost);
			__instance.CheckLock();
			MethodInfo methodInfo = AccessTools.Method(typeof(UIActivateGirl), "UpdateLockLine", (Type[])null, (Type[])null);
			methodInfo.Invoke(val, null);
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(UIActivateGirlSlot), "CheckLock")]
public static class UIActivateGirlSlotCheckLockPatch
{
	private static void Postfix(UIActivateGirlSlot __instance)
	{
		if (!DataMgr.selectedWorldData.activateGirlActivatedIDs2.Contains(__instance.Config.id))
		{
			((Component)__instance.image_Unlocked).gameObject.SetActive(false);
		}
		else
		{
			((Component)__instance.image_Unlocked).gameObject.SetActive(true);
		}
	}
}
namespace ResettableUnlocks
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ResettableUnlocks";

		public const string PLUGIN_NAME = "ResettableUnlocks";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}