Decompiled source of Dev Cheat Screen v1.0.0

Patty_DevCheatScreen_MOD.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ShinyShoe;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Patty_DevCheatScreen_MOD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Patty_DevCheatScreen_MOD")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f7a198de-41d0-4632-af31-f80bd4143d65")]
[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 Patty_DevCheatScreen_MOD;

internal class PatchList
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(AppManager), "DoesThisBuildReportErrors")]
	public static void DisableErrorReportingPatch(ref bool __result)
	{
		__result = false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(CheatScreen), "AddCheat")]
	public static void AddCheat(CheatScreen __instance, string label, string category, CheatTriggerDelegate cheatTriggerDelegate, bool closeCheatScreenOnTrigger, LayoutGroup layoutGroup)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		Traverse val = Traverse.Create((object)__instance);
		Transform val2 = ((Component)val.Field<ScreenDialog>("_cheatScreenDialog").Value).transform.Find(((object)(LayoutGroup)(ref layoutGroup)).ToString() + " content/CheatsArea");
		if ((Object)(object)val2 == (Object)null)
		{
			Plugin.LogSource.LogError((object)$"Cannot find layout: {layoutGroup} content/CheatsArea");
			return;
		}
		GameUISelectableButton val3 = Object.Instantiate<GameUISelectableButton>(val.Field<GameUISelectableButton>("cheatButton").Value, val2);
		((Component)val3).gameObject.SetActive(true);
		Type value = val.Type("Cheat").GetValue<Type>();
		object obj = Activator.CreateInstance(value, val3, label, category, cheatTriggerDelegate, closeCheatScreenOnTrigger);
		Type type = typeof(List<>).MakeGenericType(value);
		type.GetMethod("Add", AccessTools.allDeclared).Invoke(val.Field("cheats").GetValue(), new object[1] { obj });
		__instance.Relabel(label, label);
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency("Patty_DevConsole_MOD", "1.2.0")]
[BepInPlugin("Patty_DevCheatScreen_MOD", "Dev Cheat Screen", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	internal static string BasePath { get; } = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName;


	internal static ManualLogSource LogSource { get; private set; }

	internal static Harmony PluginHarmony { get; private set; }

	internal static ConfigEntry<KeyCode> CheatHotkey { get; private set; }

	private void Awake()
	{
		//IL_002c: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		LogSource = ((BaseUnityPlugin)this).Logger;
		try
		{
			PluginHarmony = Harmony.CreateAndPatchAll(typeof(PatchList), "Patty_DevCheatScreen_MOD");
		}
		catch (HarmonyException val)
		{
			HarmonyException val2 = val;
			LogSource.LogError((object)((Exception)(((object)((Exception)(object)val2).InnerException) ?? ((object)val2))).Message);
		}
		CheatHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(new ConfigDefinition("Hotkey", "Open/Close"), (KeyCode)283, (ConfigDescription)null);
	}

	private void Update()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		if (!Input.GetKeyDown(CheatHotkey.Value))
		{
			return;
		}
		if ((Object)(object)AllGameManagers.Instance == (Object)null)
		{
			LogSource.LogError((object)"AllGameManagers isn't available. Try waiting a bit more before opening the menu");
			return;
		}
		ScreenManager screenManager = AllGameManagers.Instance.GetScreenManager();
		if ((Object)(object)screenManager == (Object)null)
		{
			LogSource.LogError((object)"ScreenManager isn't available. Try waiting a bit more before opening the menu");
			return;
		}
		bool screenActive = screenManager.GetScreenActive((ScreenName)8);
		screenManager.SetScreenActive((ScreenName)8, !screenActive, (ScreenActiveCallback)null);
	}
}
public static class PluginInfo
{
	public const string GUID = "Patty_DevCheatScreen_MOD";

	public const string Name = "Dev Cheat Screen";

	public const string Version = "1.0.0";
}