Decompiled source of ATMDepositMod v1.0.1

ATMDepositMod.dll

Decompiled 2 months 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 ATMDepositMod;
using HarmonyLib;
using Il2CppScheduleOne.Money;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Main), "ATM Deposit Limit Mod", "1.0.1", "helboy1337", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ATMDepositMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Mod om ATM deposit limit te verhogen")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ATMDepositMod")]
[assembly: AssemblyTitle("ATMDepositMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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;
		}
	}
}
namespace ATMDepositMod
{
	public class Main : MelonMod
	{
		private const float NEW_DEPOSIT_LIMIT = 1000000f;

		private bool initialized = false;

		public override void OnSceneWasInitialized(int buildIndex, string sceneName)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			try
			{
				if (!initialized)
				{
					((MelonBase)this).LoggerInstance.Msg("Initializing ATM Deposit Limit Mod...");
					Harmony val = new Harmony("com.user.atmmod");
					MethodInfo method = typeof(ATM).GetMethod("Interacted", BindingFlags.Instance | BindingFlags.Public);
					MethodInfo method2 = typeof(Main).GetMethod("InteractedPostfix", BindingFlags.Static | BindingFlags.NonPublic);
					if (method != null && method2 != null)
					{
						val.Patch((MethodBase)method, (HarmonyMethod)null, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						((MelonBase)this).LoggerInstance.Msg("Successfully patched ATM Interacted method!");
					}
					else
					{
						((MelonBase)this).LoggerInstance.Error("Failed to patch ATM Interacted method!");
					}
					MethodInfo method3 = typeof(ATM).GetMethod("Enter", BindingFlags.Instance | BindingFlags.Public);
					MethodInfo method4 = typeof(Main).GetMethod("EnterPostfix", BindingFlags.Static | BindingFlags.NonPublic);
					if (method3 != null && method4 != null)
					{
						val.Patch((MethodBase)method3, (HarmonyMethod)null, new HarmonyMethod(method4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						((MelonBase)this).LoggerInstance.Msg("Successfully patched ATM Enter method!");
					}
					else
					{
						((MelonBase)this).LoggerInstance.Error("Failed to patch ATM Enter method!");
					}
					initialized = true;
					((MelonBase)this).LoggerInstance.Msg("ATM Deposit Limit Mod successfully initialized!");
				}
			}
			catch (Exception ex)
			{
				((MelonBase)this).LoggerInstance.Error("Initialization error: " + ex.Message);
				((MelonBase)this).LoggerInstance.Error("Stack trace: " + ex.StackTrace);
			}
		}

		private static void ModifyATMLimits(ATM atm)
		{
			try
			{
				if ((Object)(object)atm == (Object)null)
				{
					MelonLogger.Error("ATM instance is null!");
					return;
				}
				Type type = ((object)atm).GetType();
				PropertyInfo property = type.GetProperty("WEEKLY_DEPOSIT_LIMIT");
				if (property != null)
				{
					property.SetValue(atm, 1000000f);
					MelonLogger.Msg($"WEEKLY_DEPOSIT_LIMIT set to {1000000f:N0}");
				}
				else
				{
					MelonLogger.Warning("WEEKLY_DEPOSIT_LIMIT property not found");
				}
				PropertyInfo property2 = type.GetProperty("DepositLimitEnabled");
				if (property2 != null)
				{
					property2.SetValue(atm, false);
					MelonLogger.Msg("DepositLimitEnabled set to false");
				}
				else
				{
					MelonLogger.Warning("DepositLimitEnabled property not found");
				}
				PropertyInfo property3 = type.GetProperty("WeeklyDepositSum");
				if (property3 != null)
				{
					property3.SetValue(atm, 0f);
					MelonLogger.Msg("WeeklyDepositSum reset to 0");
				}
				else
				{
					MelonLogger.Warning("WeeklyDepositSum property not found");
				}
				MelonLogger.Msg("ATM limits successfully modified!");
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Error modifying ATM limits: " + ex.Message);
				MelonLogger.Error("Stack trace: " + ex.StackTrace);
			}
		}

		private static void InteractedPostfix(ATM __instance)
		{
			try
			{
				MelonLogger.Msg("ATM interacted!");
				ModifyATMLimits(__instance);
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Error in Interacted postfix: " + ex.Message);
			}
		}

		private static void EnterPostfix(ATM __instance)
		{
			try
			{
				MelonLogger.Msg("ATM entered!");
				ModifyATMLimits(__instance);
			}
			catch (Exception ex)
			{
				MelonLogger.Error("Error in Enter postfix: " + ex.Message);
			}
		}
	}
}