Decompiled source of Max Roaches v1.3.0

plugins/MaxRoaches.dll

Decompiled 2 weeks ago
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MaxRoaches")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MaxRoaches")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e9ba2d9c-3a78-4768-b824-a3207cf7cfe5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MaxRoaches
{
	[BepInPlugin("nachariah.whiteknuckle.maxroaches", "MaxRoaches", "1.3.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string pluginGuid = "nachariah.whiteknuckle.maxroaches";

		public static bool RoachesMaxed;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[MaxRoaches] Loaded");
			Harmony val = new Harmony("whiteknuckle.maxroaches");
			val.PatchAll();
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name == "Game-Main")
			{
				RoachesMaxed = false;
				CommandConsole.hasCheated = true;
				CL_GameManager.gamemode.allowAchievements = false;
				CL_GameManager.gamemode.allowCheatedScores = false;
			}
		}
	}
}
namespace MaxRoaches.Patches
{
	[HarmonyPatch(typeof(CL_GameManager), "WithdrawRoachesFromGlobalBank")]
	public class AddRoaches
	{
		[HarmonyPrefix]
		public static void Prefix(ref int i)
		{
			if (!Plugin.RoachesMaxed)
			{
				Plugin.RoachesMaxed = true;
				Debug.Log((object)"[MaxRoaches] Maxing Roaches");
				i = 999;
			}
		}
	}
	[HarmonyPatch(typeof(UI_RoachBankPopup), "PopupAnimation")]
	public class Patch_PopupAnimation
	{
		private static readonly FieldRef<UI_RoachBankPopup, bool> showingAnimationRef = AccessTools.FieldRefAccess<UI_RoachBankPopup, bool>("showingAnimation");

		private static readonly FieldRef<UI_RoachBankPopup, RectTransform> rectTransformRef = AccessTools.FieldRefAccess<UI_RoachBankPopup, RectTransform>("rectTransform");

		private static readonly FieldRef<UI_RoachBankPopup, Vector2> rootPositonRef = AccessTools.FieldRefAccess<UI_RoachBankPopup, Vector2>("rootPositon");

		[HarmonyPrefix]
		public static bool Prefix(UI_RoachBankPopup __instance, ref IEnumerator __result, int roaches, int credits, int roachStart, int creditStart)
		{
			__result = ModifiedAnimation(__instance, roaches, credits, roachStart, creditStart);
			return false;
		}

		private static IEnumerator ModifiedAnimation(UI_RoachBankPopup __instance, int roaches, int credits, int roachStart, int creditStart)
		{
			if (showingAnimationRef.Invoke(__instance))
			{
				while (showingAnimationRef.Invoke(__instance))
				{
					yield return null;
				}
			}
			int curRoaches = roachStart;
			int curCredits = creditStart;
			showingAnimationRef.Invoke(__instance) = true;
			TweenSettingsExtensions.SetUpdate<TweenerCore<Vector2, Vector2, VectorOptions>>(DOTween.To((DOGetter<Vector2>)(() => rectTransformRef.Invoke(__instance).anchoredPosition), (DOSetter<Vector2>)delegate(Vector2 x)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				rectTransformRef.Invoke(__instance).anchoredPosition = x;
			}, rootPositonRef.Invoke(__instance), __instance.openSpeed), true);
			__instance.roachText.text = curRoaches.ToString();
			__instance.creditText.text = curCredits.ToString();
			yield return (object)new WaitForSecondsRealtime(__instance.openSpeed);
			ShortcutExtensions.DOPunchScale(((Component)__instance).transform, Vector3.one * 0.05f, 0.5f, 3, 1.2f);
			float a = 0f;
			float step = 0.00025f;
			while (Mathf.Max(Mathf.Abs(roaches), Mathf.Abs(credits)) > 0)
			{
				if (roaches > 0)
				{
					roaches--;
					curRoaches++;
				}
				else if (roaches < 0)
				{
					roaches++;
					curRoaches--;
				}
				if (credits > 0)
				{
					credits--;
					curCredits++;
				}
				else if (credits < 0)
				{
					credits++;
					curCredits--;
				}
				__instance.roachText.text = curRoaches.ToString();
				__instance.creditText.text = curCredits.ToString();
				a = Mathf.Clamp(a + step, 0f, 0.045f);
				step = Mathf.Max(step / 1.0045f, 1E-05f);
				yield return (object)new WaitForSecondsRealtime(0.05f - a);
			}
			yield return (object)new WaitForSecondsRealtime(__instance.holdTime);
			TweenSettingsExtensions.SetEase<TweenerCore<Vector2, Vector2, VectorOptions>>(TweenSettingsExtensions.SetUpdate<TweenerCore<Vector2, Vector2, VectorOptions>>(DOTween.To((DOGetter<Vector2>)(() => rectTransformRef.Invoke(__instance).anchoredPosition), (DOSetter<Vector2>)delegate(Vector2 x)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				rectTransformRef.Invoke(__instance).anchoredPosition = x;
			}, rootPositonRef.Invoke(__instance) + __instance.hidePositionOffset, __instance.openSpeed), true), (Ease)4);
			yield return (object)new WaitForSecondsRealtime(__instance.openSpeed);
			showingAnimationRef.Invoke(__instance) = false;
		}
	}
}