Decompiled source of MoreDeals v1.0.3

MoreDeals.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using MelonLoader;
using MoreDeals;
using ScheduleOne.Economy;
using ScheduleOne.GameTime;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(TestClassMod), "MoreDeals", "1.0.3", "GreenCarrot", null)]
[assembly: MelonColor]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("MoreDeals")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MoreDeals")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("759664be-814f-4966-a9bb-cff7716c98fc")]
[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 MoreDeals;

public class TestClassMod : MelonMod
{
	private Customer testCustomer = null;

	public override void OnInitializeMelon()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Expected O, but got Unknown
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Expected O, but got Unknown
		Harmony val = new Harmony("com.moredeals.customerpatch");
		try
		{
			ConstructorInfo constructor = typeof(CustomerData).GetConstructor(BindingFlags.Instance | BindingFlags.Public, null, Type.EmptyTypes, null);
			MethodInfo method = typeof(CustomerCooldownPatch).GetMethod("Postfix", BindingFlags.Static | BindingFlags.Public);
			val.Patch((MethodBase)constructor, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo method2 = typeof(Customer).GetMethod("ShouldTryGenerateDeal", BindingFlags.Instance | BindingFlags.NonPublic);
			MethodInfo method3 = typeof(ShouldTryGenerateDealPatch).GetMethod("Transpiler", BindingFlags.Static | BindingFlags.Public);
			val.Patch((MethodBase)method2, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(method3), (HarmonyMethod)null);
			MethodInfo method4 = typeof(Customer).GetMethod("CheckContractGeneration", BindingFlags.Instance | BindingFlags.NonPublic);
			MethodInfo method5 = typeof(CheckContractGenerationPatch).GetMethod("Transpiler", BindingFlags.Static | BindingFlags.Public);
			val.Patch((MethodBase)method4, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(method5), (HarmonyMethod)null);
			MelonLogger.Msg("Manual patches applied.");
		}
		catch (Exception arg)
		{
			MelonLogger.Error($"Error applying manual patches: {arg}");
		}
		MelonLogger.Msg("MoreDeals Mod Initialized.");
	}
}
[HarmonyPatch(typeof(CustomerData))]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static class CustomerCooldownPatch
{
	[HarmonyPostfix]
	public static void Postfix(CustomerData __instance)
	{
		__instance.MinOrdersPerWeek = 7;
		__instance.MaxOrdersPerWeek = 7;
		__instance.MinWeeklySpend = 5000f;
		__instance.MaxWeeklySpend = 10000f;
	}
}
[HarmonyPatch(typeof(Customer), "ShouldTryGenerateDeal")]
public static class ShouldTryGenerateDealPatch
{
	[HarmonyTranspiler]
	public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		foreach (CodeInstruction instruction in instructions)
		{
			if (instruction.opcode == OpCodes.Ldc_I4 && instruction.operand is int intVal && intVal == 600)
			{
				instruction.operand = 150;
			}
			yield return instruction;
		}
	}
}
[HarmonyPatch(typeof(Customer), "CheckContractGeneration")]
public static class CheckContractGenerationPatch
{
	[HarmonyTranspiler]
	public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		List<CodeInstruction> list = new List<CodeInstruction>(instructions);
		MethodInfo methodInfo = AccessTools.Method(typeof(TimeManager), "AddMinutesTo24HourTime", (Type[])null, (Type[])null);
		for (int i = 0; i < list.Count; i++)
		{
			if (list[i].opcode == OpCodes.Call && list[i].operand == methodInfo)
			{
				list[i - 1] = new CodeInstruction(OpCodes.Ldc_I4, (object)700);
			}
		}
		return list.AsEnumerable();
	}
}