Decompiled source of AutoInterest v1.0.1

AutoInterest.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.Mono;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MyMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MyMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eb6b4302-5fdc-4501-839a-82a96d3d0cce")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("ru.mjkey.autointerest", "Auto Interest Mod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameplayData), "InterestEarnedGrow")]
		private static void AfterInterestGrow()
		{
			try
			{
				Type typeFromHandle = typeof(GameplayData);
				if (typeFromHandle == null)
				{
					Logger.LogWarning((object)"GameplayData type not found. Skipping InterestPickUp.");
				}
				else
				{
					GameplayData.InterestPickUp();
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Error while trying to auto-pick up interest: " + ex));
			}
		}
	}

	internal static ManualLogSource Logger;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		Logger = ((BaseUnityPlugin)this).Logger;
		try
		{
			_harmony = new Harmony("ru.mjkey.autointerest");
			_harmony.PatchAll(typeof(Patches));
			Logger.LogInfo((object)"Auto Interest Mod loaded and patches applied.");
		}
		catch (Exception ex)
		{
			Logger.LogError((object)("Failed to apply Harmony patches: " + ex));
		}
	}

	private void OnDestroy()
	{
		try
		{
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
			Logger.LogInfo((object)"Auto Interest Mod unloaded and patches removed.");
		}
		catch (Exception ex)
		{
			Logger.LogError((object)("Failed to remove Harmony patches: " + ex));
		}
	}
}