Decompiled source of PForProduct v1.0.0

PForProduct.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Phone;
using Il2CppScheduleOne.UI.Phone.ProductManagerApp;
using MelonLoader;
using P_For_Product;
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: MelonInfo(typeof(PForProduct), "Product Hotkey Mod", "1.0.0", "KHK", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: AssemblyTitle("Product Hotkey Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Product Hotkey Mod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4e6edb57-1af5-4c7b-babb-4e2af88c640a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace P_For_Product;

public class PForProduct : MelonMod
{
	private const KeyCode TOGGLE_KEY = 112;

	private bool isInitialized = false;

	public override void OnInitializeMelon()
	{
		MelonLogger.Msg("PForProduct Mod initialized.");
	}

	public override void OnSceneWasLoaded(int buildIndex, string sceneName)
	{
		if (sceneName != "Main")
		{
			MelonLogger.Msg("Scene '" + sceneName + "' detected. Product Manager is disabled in non-gameplay scenes.");
			isInitialized = false;
		}
		else
		{
			MelonCoroutines.Start(InitializeMod());
		}
	}

	private IEnumerator InitializeMod()
	{
		yield return (object)new WaitForSeconds(1f);
		try
		{
			MelonLogger.Msg("Product Manager Mod Ready in Main Scene.");
			isInitialized = true;
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Error initializing Product Manager: " + ex.Message);
		}
	}

	public override void OnUpdate()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		if (isInitialized)
		{
			Scene activeScene = SceneManager.GetActiveScene();
			if (!(((Scene)(ref activeScene)).name != "Main") && Input.GetKeyDown((KeyCode)112))
			{
				Toggle();
			}
		}
	}

	private void Toggle()
	{
		try
		{
			GameplayMenu val = Object.FindObjectOfType<GameplayMenu>();
			ProductManagerApp val2 = Object.FindObjectOfType<ProductManagerApp>();
			Phone val3 = Object.FindObjectOfType<Phone>();
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
			{
				MelonLogger.Warning("One or more required UI components were not found.");
			}
			else if (val.IsOpen)
			{
				if ((Object)(object)Phone.ActiveApp == (Object)(object)((Component)val2).gameObject)
				{
					MelonLogger.Msg("Closing the phone.");
					val.SetIsOpen(false);
				}
				else
				{
					MelonLogger.Msg("Switching to the Product Manager App.");
					((App<ProductManagerApp>)(object)val2).SetOpen(true);
				}
			}
			else
			{
				MelonLogger.Msg("Opening the phone with the Product Manager App.");
				val.SetIsOpen(true);
				((App<ProductManagerApp>)(object)val2).SetOpen(true);
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Error("Error toggling Product Manager: " + ex.Message);
		}
	}

	public override void OnDeinitializeMelon()
	{
		GameplayMenu val = Object.FindObjectOfType<GameplayMenu>();
		if ((Object)(object)val != (Object)null && val.IsOpen)
		{
			val.SetIsOpen(false);
		}
	}
}