Decompiled source of XPAdjuster v1.0.2

XPAdjuster_Alternate.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using ScheduleOne.Economy;
using ScheduleOne.Levelling;
using ScheduleOne_XPAdjuster;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "ScheduleOne_XPAdjuster", "1.0.2", "Apatel78", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("XPAdjuster_Alternate")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f5d0efe3f3e3600a94c09793556c9b691771b53c")]
[assembly: AssemblyProduct("XPAdjuster_Alternate")]
[assembly: AssemblyTitle("XPAdjuster_Alternate")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 ScheduleOne_XPAdjuster
{
	public static class ModConfig
	{
		public static string config_path = Path.Combine(MelonEnvironment.UserDataDirectory, "XPAdjuster");

		private static MelonPreferences_Category XPCategory;

		public static MelonPreferences_Entry<int> PlayerCompletedDeal;

		public static MelonPreferences_Entry<int> DealerCompletedDeal;

		public static MelonPreferences_Entry<int> EscapedWanted;

		public static MelonPreferences_Entry<int> EscapedWanted2;

		public static MelonPreferences_Entry<int> EscapedArrest;

		public static void CreateDirectory()
		{
			Directory.CreateDirectory(config_path);
			Init();
		}

		public static void Init()
		{
			XPCategory = MelonPreferences.CreateCategory("XP Adjustments");
			PlayerCompletedDeal = XPCategory.CreateEntry<int>("Player Completed Deal XP", 20, "XP awarded when the player completes a deal.", (string)null, false, false, (ValueValidator)null, (string)null);
			DealerCompletedDeal = XPCategory.CreateEntry<int>("Dealer Completed Deal XP", 10, "XP awarded when a dealer completes a deal.", (string)null, false, false, (ValueValidator)null, (string)null);
			EscapedWanted = XPCategory.CreateEntry<int>("Escaped Wanted Level 1 XP", 40, "XP awarded for escaping wanted.", (string)null, false, false, (ValueValidator)null, (string)null);
			EscapedWanted2 = XPCategory.CreateEntry<int>("Escaped Wanted Level 2 XP", 60, "XP awarded for escaping wanted deal or alive.", (string)null, false, false, (ValueValidator)null, (string)null);
			EscapedArrest = XPCategory.CreateEntry<int>("Escaped Arrest XP", 20, "XP awarded for escaping under arrest.", (string)null, false, false, (ValueValidator)null, (string)null);
			XPCategory.SetFilePath(Path.Combine(config_path, "XPAdjusterConfig.cfg"));
			XPCategory.SaveToFile(true);
		}
	}
	public class Core : MelonMod
	{
		[HarmonyPatch(typeof(LevelManager), "AddXP")]
		public class Patch_LevelManager_AddXP
		{
			private static bool Prefix(ref int xp)
			{
				if (xp == 10)
				{
					xp = DealerCompletedDealXP;
					PlayerDealChecker.IsProcessHandoverCalled = false;
				}
				else if (xp == 20)
				{
					if (PlayerDealChecker.IsProcessHandoverCalled)
					{
						xp = PlayerCompletedDealXP;
						PlayerDealChecker.IsProcessHandoverCalled = false;
					}
					else
					{
						xp = EscapedArrestXP;
					}
				}
				else if (xp == 40)
				{
					xp = EscapedWantedXP;
				}
				else if (xp == 60)
				{
					xp = EscapedWanted2XP;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Customer), "ProcessHandover")]
		public class Patch_Customer_ProcessHandover
		{
			private static void Prefix(Customer __instance)
			{
				PlayerDealChecker.IsProcessHandoverCalled = true;
			}
		}

		public static class PlayerDealChecker
		{
			public static bool IsProcessHandoverCalled;
		}

		public static int PlayerCompletedDealXP;

		public static int DealerCompletedDealXP;

		public static int EscapedWantedXP;

		public static int EscapedWanted2XP;

		public static int EscapedArrestXP;

		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
			Harmony val = new Harmony("com.apatel.schedule1.xppatch");
			val.PatchAll();
			ModConfig.CreateDirectory();
			PlayerCompletedDealXP = ModConfig.PlayerCompletedDeal.Value;
			DealerCompletedDealXP = ModConfig.DealerCompletedDeal.Value;
			EscapedWantedXP = ModConfig.EscapedWanted.Value;
			EscapedWanted2XP = ModConfig.EscapedWanted2.Value;
			EscapedArrestXP = ModConfig.EscapedArrest.Value;
		}
	}
}

XPAdjuster_Main.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2CppScheduleOne.Economy;
using Il2CppScheduleOne.Levelling;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using XPAdjusterMain;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Core), "XPAdjusterMain", "1.0.2", "Arsh", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("XPAdjuster_Main")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f5d0efe3f3e3600a94c09793556c9b691771b53c")]
[assembly: AssemblyProduct("XPAdjuster_Main")]
[assembly: AssemblyTitle("XPAdjuster_Main")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 XPAdjusterMain
{
	public static class ModConfig
	{
		public static string config_path = Path.Combine(MelonEnvironment.UserDataDirectory, "XPAdjuster");

		private static MelonPreferences_Category XPCategory;

		public static MelonPreferences_Entry<int> PlayerCompletedDeal;

		public static MelonPreferences_Entry<int> DealerCompletedDeal;

		public static MelonPreferences_Entry<int> EscapedWanted;

		public static MelonPreferences_Entry<int> EscapedWanted2;

		public static MelonPreferences_Entry<int> EscapedArrest;

		public static void CreateDirectory()
		{
			Directory.CreateDirectory(config_path);
			Init();
		}

		public static void Init()
		{
			XPCategory = MelonPreferences.CreateCategory("XP Adjustments");
			PlayerCompletedDeal = XPCategory.CreateEntry<int>("Player Completed Deal XP", 20, "XP awarded when the player completes a deal.", (string)null, false, false, (ValueValidator)null, (string)null);
			DealerCompletedDeal = XPCategory.CreateEntry<int>("Dealer Completed Deal XP", 10, "XP awarded when a dealer completes a deal.", (string)null, false, false, (ValueValidator)null, (string)null);
			EscapedWanted = XPCategory.CreateEntry<int>("Escaped Wanted Level 1 XP", 40, "XP awarded for escaping wanted.", (string)null, false, false, (ValueValidator)null, (string)null);
			EscapedWanted2 = XPCategory.CreateEntry<int>("Escaped Wanted Level 2 XP", 60, "XP awarded for escaping wanted deal or alive.", (string)null, false, false, (ValueValidator)null, (string)null);
			EscapedArrest = XPCategory.CreateEntry<int>("Escaped Arrest XP", 20, "XP awarded for escaping under arrest.", (string)null, false, false, (ValueValidator)null, (string)null);
			XPCategory.SetFilePath(Path.Combine(config_path, "XPAdjusterConfig.cfg"));
			XPCategory.SaveToFile(true);
		}
	}
	public class Core : MelonMod
	{
		[HarmonyPatch(typeof(LevelManager), "AddXP")]
		public class Patch_LevelManager_AddXP
		{
			private static bool Prefix(ref int xp)
			{
				if (xp == 10)
				{
					xp = DealerCompletedDealXP;
					PlayerDealChecker.IsProcessHandoverCalled = false;
				}
				else if (xp == 20)
				{
					if (PlayerDealChecker.IsProcessHandoverCalled)
					{
						xp = PlayerCompletedDealXP;
						PlayerDealChecker.IsProcessHandoverCalled = false;
					}
					else
					{
						xp = EscapedArrestXP;
					}
				}
				else if (xp == 40)
				{
					xp = EscapedWantedXP;
				}
				else if (xp == 60)
				{
					xp = EscapedWanted2XP;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Customer), "ProcessHandover")]
		public class Patch_Customer_ProcessHandover
		{
			private static void Prefix(Customer __instance)
			{
				PlayerDealChecker.IsProcessHandoverCalled = true;
			}
		}

		public static class PlayerDealChecker
		{
			public static bool IsProcessHandoverCalled;
		}

		public static int PlayerCompletedDealXP;

		public static int DealerCompletedDealXP;

		public static int EscapedWantedXP;

		public static int EscapedWanted2XP;

		public static int EscapedArrestXP;

		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
			Harmony val = new Harmony("com.apatel.schedule1.xppatch");
			val.PatchAll();
			ModConfig.CreateDirectory();
			PlayerCompletedDealXP = ModConfig.PlayerCompletedDeal.Value;
			DealerCompletedDealXP = ModConfig.DealerCompletedDeal.Value;
			EscapedWantedXP = ModConfig.EscapedWanted.Value;
			EscapedWanted2XP = ModConfig.EscapedWanted2.Value;
			EscapedArrestXP = ModConfig.EscapedArrest.Value;
		}
	}
}