Decompiled source of Cheaper Lure Restock v1.0.0

BepInEx/plugins/MixedPatch_CheaperLureRestock.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Players;
using Riverboat.UGS;
using TMPro;
using UI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MixedPatch_CheaperLureRestock")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MixedPatch_CheaperLureRestock")]
[assembly: AssemblyTitle("MixedPatch_CheaperLureRestock")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Voodoo_QOL;

[HarmonyPatch]
public static class AddMoneyCapturePatch
{
}
[HarmonyPatch]
public static class HotkeyUpdatePatch
{
	public static MethodBase TargetMethod()
	{
		return AccessTools.Method(typeof(PlayerCameraOverrideMovement), "Update", (Type[])null, (Type[])null);
	}

	public static void Postfix()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		if (!Input.GetKeyDown((KeyCode)289))
		{
			return;
		}
		PlayerSaveData instance = PlayerSaveData.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			((BasePlugin)Plugin.Instance).Log.LogWarning((object)"PlayerSaveData.Instance is null.");
			return;
		}
		int money = instance.GetMoney();
		instance.AddMoney(500);
		int money2 = instance.GetMoney();
		ManualLogSource log = ((BasePlugin)Plugin.Instance).Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Money before: ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(money);
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", after: ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(money2);
		}
		log.LogInfo(val);
	}
}
[BepInPlugin("com.mixedpatch.cheaperlurerestock", "Voodoo Cheaper Lure Restock", "1.0.0")]
public class Plugin : BasePlugin
{
	internal static Plugin Instance;

	public override void Load()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Expected O, but got Unknown
		Instance = this;
		((BasePlugin)this).Log.LogInfo((object)"Voodoo Cheaper Lure Restock loading...");
		Harmony val = new Harmony("com.mixedpatch.cheaperlurerestock");
		MethodBase methodBase = RestockBaitPatch.TargetMethod();
		((BasePlugin)this).Log.LogInfo((object)((methodBase == null) ? "RestockBait not found." : $"RestockBait found: {methodBase}"));
		val.Patch(methodBase, new HarmonyMethod(AccessTools.Method(typeof(RestockBaitPatch), "Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((BasePlugin)this).Log.LogInfo((object)"Voodoo Cheaper Lure Restock Loaded!");
	}
}
[HarmonyPatch]
public static class RestockBaitPatch
{
	public static MethodBase TargetMethod()
	{
		return AccessTools.Method(typeof(TackleShopUI), "RestockBait", (Type[])null, (Type[])null);
	}

	public static bool Prefix(TackleShopUI __instance)
	{
		int restockBaitPrice = __instance.restockBaitPrice;
		PlayerSaveData instance = PlayerSaveData.Instance;
		if ((Object)(object)instance == (Object)null)
		{
			return false;
		}
		if (instance.GetMoney() < restockBaitPrice)
		{
			return false;
		}
		instance.RemoveMoney(restockBaitPrice);
		__instance._tackleShopController.NetworkController.RequestRestockBaitRpc();
		__instance.restockBaitPrice = restockBaitPrice + restockBaitPrice / 10;
		((Component)__instance.restockBaitButton).GetComponentInChildren<TMP_Text>().text = PriceFormatter.FormatPrice(__instance.restockBaitPrice, true, "$");
		AccessTools.Method(typeof(TackleShopUI), "UpdatePriceColor", (Type[])null, (Type[])null)?.Invoke(__instance, new object[1] { __instance.restockBaitPrice });
		return false;
	}
}