Decompiled source of NoPurchaseNeeded v1.0.0

ShopFreeRevive.dll

Decompiled 3 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 BepInEx;
using HarmonyLib;

[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("ShopFreeRevive")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShopFreeRevive")]
[assembly: AssemblyTitle("ShopFreeRevive")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ShopFreeRevive;

[BepInPlugin("com.bfind.shopfreerevive", "ShopFreeRevive", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private Harmony harmony;

	private void Awake()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		harmony = new Harmony("com.bfind.shopfreerevive");
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"ShopFreeRevive loaded! Players can now be revived for free at the shop.");
	}

	private void OnDestroy()
	{
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
	}
}
[HarmonyPatch(typeof(ExtractionPoint), "OnShopClick")]
public static class OnShopClickPatch
{
	private static bool Prefix(ExtractionPoint __instance)
	{
		//IL_005e: 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)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Invalid comparison between Unknown and I4
		FieldInfo fieldInfo = AccessTools.Field(typeof(ExtractionPoint), "currentState");
		FieldInfo fieldInfo2 = AccessTools.Field(typeof(ExtractionPoint), "tubeSlamDownEval");
		FieldInfo fieldInfo3 = AccessTools.Field(typeof(ExtractionPoint), "haulCurrent");
		MethodInfo methodInfo = AccessTools.Method(typeof(ExtractionPoint), "StateSet", (Type[])null, (Type[])null);
		State val = (State)fieldInfo.GetValue(__instance);
		if ((int)val != 2)
		{
			return false;
		}
		float num = (float)fieldInfo2.GetValue(__instance);
		if (num < 1f)
		{
			return false;
		}
		int haulGoal = __instance.haulGoal;
		int num2 = (int)fieldInfo3.GetValue(__instance);
		if (haulGoal - num2 >= 0)
		{
			methodInfo.Invoke(__instance, new object[1] { (object)(State)3 });
		}
		else
		{
			methodInfo.Invoke(__instance, new object[1] { (object)(State)5 });
		}
		return false;
	}
}
[HarmonyPatch(typeof(ExtractionPoint), "CancelExtraction")]
public static class CancelExtractionPatch
{
	private static bool Prefix(ExtractionPoint __instance, ref bool __result)
	{
		FieldInfo fieldInfo = AccessTools.Field(typeof(ExtractionPoint), "isShop");
		if (!(bool)fieldInfo.GetValue(__instance))
		{
			return true;
		}
		FieldInfo fieldInfo2 = AccessTools.Field(typeof(ExtractionPoint), "haulCurrent");
		int num = SemiFunc.ShopGetTotalCost() * 1000;
		fieldInfo2.SetValue(__instance, num);
		int haulGoal = __instance.haulGoal;
		MethodInfo methodInfo = AccessTools.Method(typeof(ExtractionPoint), "StateSet", (Type[])null, (Type[])null);
		if (haulGoal - num < 0)
		{
			methodInfo.Invoke(__instance, new object[1] { (object)(State)5 });
			__result = true;
		}
		else
		{
			__result = false;
		}
		return false;
	}
}